Home > DeveloperSection > Forums > What type of join should I use?
Chintoo Semi

Total Post:135

Points:947
Posted on    March-11-2013 3:44 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 927  View(s)
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!



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    March-11-2013 8:41 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick