What type of join should I use?

Total Post:135

Points:947
 1649  View(s)
Ratings:
Rate this:

Hi All!

My join knowledge is terrible, I can't find the correct one for this. I want to join the two tables on the TableA.userID and the TableB.otherID to match the

desired output. I don't have any foreign or primary keys set on the tables. What should I be using here?

TableA:

userID
field1 
field2 


TableB:

userID
otherID
myData1
myData2
myData3


Desired Output:

userID
otherID
myData1
myData2
myData3
field1
field2

Thanks in advance!

  1. Post:604

    Points:4228
    Re: What type of join should I use?

    Hi Chintto!

    As par your code, you can apply inner join as following

    select a.userID, b.otherID, b.myData1, b.myData2, b.myData3, a.field1, a.field1
    from TableA a
    inner join TableB b
    on a.userID = b.otherID

Answer