mysql - Complicated (my)SQL left join -



mysql - Complicated (my)SQL left join -

is possible have left bring together give result in next assumption:

table a:

id value 1 foo 2 bar 3 foobar

table b:

foreign foreign_value 1 fish 1 soup

the result of bring together should every result of table (left join) , additionally joined results beetween , b:

select * complicated bring together b on a.id=b.foreign:

id value foreign foreign_value 1 foo null null 1 foo 1 fish 1 foo 1 soup 2 bar null null 3 foobar null null

when doing normal left bring together first row of shown example-resultset not exist.

is such select possible?

no, such bring together not possible, because not first line.

you utilize union

select a.id, a.value, b.foreign, b.foreign_value inner bring together b on a.id=b.foreign union select a.id, a.value, null, null

this give expected result in example, don't understand why seek this. hence don't know if gives expected result in general case.

mysql join null left-join

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -