0

this question is a bit of a mouthful.

express this question by example

there are two table here:

table1
id1    col1
 1       a
 2       b
 3       c
---------------------
table2
id2    col2
 1       b
 2       c
 3       d

if i do this: select * from table1 t inner join table2 tt on t.col1=tt.col2 l will get the result like this:

id1   col1   id2    col2
  2      b     1       b
  3      c     2       c

than question coming

l want to get result like this

 id1   col1   id2    col2
   1      a  null    null
null   null     3       d
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
afraid.jpg
  • 965
  • 2
  • 14
  • 31
  • You want a full outer join: https://stackoverflow.com/questions/4796872/how-to-do-a-full-outer-join-in-mysql – juergen d Jul 11 '18 at 04:35

1 Answers1

0

You would normally use a Full outer join but in mysql you can try the following:

SELECT * FROM table1 t
LEFT JOIN table2 tt ON t.col1=tt.col2
UNION
SELECT * FROM table2 tt
LEFT JOIN table1 t ON t.col1=tt.col2
Ankur Patel
  • 1,413
  • 8
  • 14