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 |
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2008-07-03 : 09:51:56
|
| Hi Friends, I have two table named as tbl_property and tbl_favoritestbl_property contain two column are id,citytbl_favorites contain 3 columns user_id,prty_id,fav_statusNow i want to display all the rows from tbl_property, from the tbl_favorites i want to display user_id which is equal to 13 and the prty_id = id and the fav_statusSample Datatbl_prty--------id city1 LA2 CA3 KL4 CD5 XL6 POtbl_favorites--------------user_id prty_id fav_status13 2 1 13 3 114 3 1Expected Output is :id city user_id fav_Status1 LA 0 2 CA 13 13 KL 13 1 4 CD 05 XL 06 PO 0Please help me in query, its very urgent...Thanks in advance |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-03 : 10:08:57
|
[code]SELECT p.id, p.city, f.user_id, f.fav_statusFROM tbl_prty p left JOIN tbl_favorites f ON p.id = f.prty_id[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|