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 |
|
Rawler
Starting Member
9 Posts |
Posted - 2009-11-11 : 13:00:34
|
hi guys, well I have a doubt about this join;I have 2 tablest1-ITEMSt1.ItemIdt1.ItemNamet2-ITEMSxUSERSt2.UserIdt2.ItemIdand I try to bring ALL items of t1, when the item is in t2 show the name and when is not show a null.I tried this and I got only the items that are in t2, any idea how to solve this?SELECT *FROM t1 LEFT JOIN t2 ON t1.ItemId = t2.ItemIdWHERE t2.UserId= 200 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-11-11 : 13:04:32
|
Change the WHERE to an AND SELECT *FROM t1 LEFT JOIN t2 ON t1.ItemId = t2.ItemIdWHERE AND t2.UserId= 200 |
 |
|
|
Rawler
Starting Member
9 Posts |
Posted - 2009-11-11 : 14:18:45
|
| ermmm it worked... wow I feel sad, such a easy solution haha I think I have to change nick or something haha thanks Lamprey you fixed my life.pd: I dont know if I have to close or submit as resolved or what to do after you solved my question, but thanks again. |
 |
|
|
|
|
|