I want to left join this query but it does not seem to work
select *,(SELECT datediff(t1.expirydate,CURDATE())as daysleft
from tbl1 t1,
left join tbl2 t2 on (t1.mid=t2.mid and t1.pid=t2.pid and t1.uid=3)
you have an error in your SQL syntax;
right syntax to use near 'left join tbl2 t2 on (t1.mid=t2.mid and t1.pid=t2.p' at line 3
Please let me know where am i wrong
here am joining 3 table but doesnt work
SELECT t1.*, t2.*,t3.* datediff(t1.expirydate, CURDATE()) AS daysleft FROM tbl1 t1 left join
tbl2 t2 on t1.mid = t2.mid and t1.pid = t2.pid left join tbl3 t3 on t3.pid = t2.pid where t1.uid=3
for knw 3 table but the i get syntax error
You don't put a comma between joins.
SELECT t1.*, t2.*, datediff(fsp.expirydate, CURDATE()) AS daysleft
FROM tbl1 t1
left join tbl2 t2 on t1.mid = t2.mid and t1.pid = t2.pid
cross join fsp
where t1.uid = 3
You also shouldn't put the
t1.uid = 3
condition in the ON
clause. ON
should only contain conditions that relate the two tables, and in the case of LEFT JOIN
it can also include conditions on the table you're joining with (t2
in this case).
0 comments:
Post a Comment