Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
atmonline
Starting Member
14 Posts |
Posted - 2008-06-26 : 21:15:51
|
| I have 2 tablesheet1 and sheet2sheet1 has cloumnsappreq,reqkey,reqdate etc...sheet2 has columnsappreq,reqkey,reqdate,assignedtobasically both tables almost have same data.but sheet3 has some more rows that are not in sheet4sheet1appkey reqkey reqdate 1 100 1 200 2 100 3 200 4 300 4 100 4 200appkey reqkey reqdate assigneto 1 100 h 1 200 wh 2 100 dsq 3 200 dsq 4 300 dsq 4 100 hI need help in writing a query whose output should look like thisappkey reqkey assignedto 1 100 h 1 200 wh 2 100 dsq 3 200 dsq 4 300 dsq 4 100 h 4 200 null Basically i need to combine these 2 tables get the ouptuti tried the regular join .but its not workingselect s1.appkey,s1.reqkey,s2.assignedto from sheet1 s1 innerjoin sheet2 s2 on sheet1.appkey=sheet2.appkey and sheet1.reqkey=sheet2.reqkeyi know its won't work because there are mutiple records in both tables. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-06-26 : 21:32:29
|
USE LEFT JOINSELECT s1.appkey, s2.reqkey, s2.assignedtoFROM sheet1 s1 left JOIN sheet2 s2 ON s1.appkey = s2.appkey AND s1.reqkey = s2.reqkey KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|