I have query that LEFT joins information from two tables. With code with following joins
LEFT JOIN A on source = news_id
LEFT JOIN B on source = other_news_id
How can join or display data from the two columns so it produces one column information.
ID source Left Join on ID a Left Join on ID b
a 1 info1 <null>
a 2 info2 <null>
b 3 <null> info3
b 4 <null> info4
Something along the lines of
ID source info
a 1 info1
a 2 info2
b 3 info3
b 4 info4
How can I bring all left joins into one column?
a.idandb.idnot null? If yes, the order inside theCOALESCE()function matters (the first non-null will be chosen). If no, you may be able to rewrite the query with aUNIONof 2 queries. - ypercubeᵀᴹ