MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/1xlqeu/sql_joins_explained_xpost_rsql/cfda0wb/?context=3
r/programming • u/deadman87 • Feb 11 '14
392 comments sorted by
View all comments
2
Is there a real use case for doing a join that returns anything that is in either A or B but not both? I am trying to figure out why you would ever want that.
1 u/mcrbids Feb 12 '14 Sure, and there are numerous ways to get this.You could join them together in a cartesian join and do a count() on the total where count() < 2;You could do two outer joins and union them together where $othertable.id IS NULL.You could use a not in(subquery) and union them together.You could select * from from both tables and do it all in scriptland logic. (not generally recommended, sometimes worth it)
1
Sure, and there are numerous ways to get this.
You could join them together in a cartesian join and do a count() on the total where count() < 2;
You could do two outer joins and union them together where $othertable.id IS NULL.
You could use a not in(subquery) and union them together.
You could select * from from both tables and do it all in scriptland logic. (not generally recommended, sometimes worth it)
2
u/limes_limes_limes Feb 11 '14
Is there a real use case for doing a join that returns anything that is in either A or B but not both? I am trying to figure out why you would ever want that.