sql - MySQL JOIN Complexity -
i using mysql 5.5 , have 2 tables t1(id, name) , t2(id, marks), following data in table.
t1's data
id name 1 2 b 3 c t2's data
id marks 1 40 5 60 and want following resultset
id name marks 1 40 2 b 0 3 c 0 what query can write accomplish above resultset?
left join 2 tables:
select t1.id, t1.name, ifnull(t2.marks, 0) marks t1 left join t2 on t1.id = t2.id;
Comments
Post a Comment