I am joining 2 tables -tbl1 and tbl2. Left join give all data from tbl1 which is in tbl2 or only on tbl1. Right join gives data from tbl2 which is don’t exists in tbl1.
I want to combine both results.
What is the best way to do this so that I get all data from tbl1 and tbl2?
The only you can do that is by using
UNION. MySQL doesn’t supportFULL JOINjust like in MSSQL.SEE HERE: Simulating FULL JOIN in MYSQL
By the way,
UNIONhas optional keywordALL,when theALLis omitted,UNIONautomatically selectsDISTINCTrows from the resultset.EXAMLE:
this can result duplicates rows
BUT if you omit the word
ALLthis can result distinct rows only