inner join


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: inner join

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    inner join

    [Originally posted by Croy]

    I have 2 tables i want to connect by inner join.

    one is "Education_subects" (has fields: "subject_id" & "subject_desc"), and the other table is "employee_education" (has fields: "emoloyee_number", "subject_id_1", "subject_id_2").

    now, i want to connect both fields "subject_id_1" & "subject_id_2" to the field "subject_id" in the first table.

    how do i do it.
    in other words, i do i connect 2 tables in more then one field?

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:inner join

    [Originally posted by Jim]

    select fields
    from tbl1 inner join tbl2
    on tbl1.field1 = tbl2.field1
    and tbl1.field2 = tbl2.field2

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:inner join

    [Originally posted by Croy]

    hi jim
    the problem is that i want to connect field1 and field2 from tbl1 to the same field(!) in tbl2.
    can i do it?
    thanks.

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:inner join

    [Originally posted by Jim]

    Is this what you need?


    select e.employee_number, s1.subject_desc, s2.subject_desc from employee_education e left join education_subjects s1 on e.subject_id_1 = s1.subject_id left join education_subjects s2 on e.subject_id_2 = s2.subject_id

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center