I have 2 tables and I am trying to join them using left join
Table 1
hid rid uid tie
1 61 566 23
2 62 322 21
3 63 455 65
4 63 223 29
Table 2
uhid
322
455
223
344
My desired output should be
uid tie
322 21
455 65
223 29
344 0
My query is
select table1.uid,table1.tie from table1 left join table2 on
table2.uhid = table1.uid
where (table1.rid=61 or table1.rid=62 or table1.rid=63)
But it gives me the following result which is not desired.
uid tie
566 23
322 21
455 65
223 29
344 0
I don't want 566 not to be included as it is not included in table 2 though it's rid is 61 and it included in where clause.
Any help is highly appreciated. Thanks in advance.
Corrected
select table1.uid,table1.tie from table2 left join table1 on
table2.uhid = table1.uid
and (table1.rid=61 or table1.rid=62 or table1.rid=63)