mysql - Is left join commutative? What are its properties? -
assume tables tablea tableb tablec , tabled:
is following query:
tablea inner join tableb left join tablec left join tabled (all joined id column) equivalent to:
tablea inner join tableb inner join tablec left join tabled union tablea inner join tableb left join tablec on tableb.c_id null left join tabled ?
note:
or instead of union
tablea inner join tableb inner join tablec left join tabled and
tablea inner join tableb left join tablec on tableb.c_id null left join tabled and combine results
update
(a inner join b) left join c left join d the same as:
a inner join (b left join c) left join d ?
wikipedia:
"in mathematics, binary operation commutative if changing order of operands not change result. fundamental property of many binary operations, , many mathematical proofs depend on it."
answer:
no, left join not commutative. , inner join is.
but that's not asking.
is following query:
tablea inner join tableb left join tablec left join tabled (all joined id column) equivalent to:
tablea inner join tableb inner join tablec left join tabled union tablea inner join tableb left join tablec on tableb.c_id null left join tabled answer:
also no. unions , joins don't accomplish same thing, speaking. in case may able write them equivalently, don't think general pseudo sql showing. on constitution seemslike should not work (maybe not know in mysql?)
here simplified set of queries think equivalent.
select * tablea left join tableb b on a.id = b.id_a select * tablea inner join tableb b on a.id = b.id_a union select * tablea left join tableb b on a.id = b.id_a tableb.id null edit 2:
here's example closer in essence same.
select * tablea inner join tableb b on a.id = b.id_a left join tablec c on b.id = c.id_b is same as
select * tablea inner join tableb b on a.id = b.id_a inner join tablec c on b.id = c.id_b union select * tablea inner join tableb b on a.id = b.id_a left join tablec c on b.id = c.id_b tablec.id null but still don't think i'm answering real question.
Comments
Post a Comment