-1

How to do full outer joins in sql lite on multiple tables? it is not supported, but is there another way to get the same result?

sg_sg94
  • 2,248
  • 4
  • 28
  • 56
  • 1
    Does this answer your question? [FULL OUTER JOIN with SQLite](https://stackoverflow.com/questions/1923259/full-outer-join-with-sqlite) – astentx Nov 03 '20 at 13:13

1 Answers1

0

A general replacement for full join is:

select a.*, b.*. -- or whatever columns you want
from a left join
     b
     on <whatever>
union all
select a.*, b.*. -- same columns as above
from b left join
     a
     on <same whatever>
where a.id is null  -- or some columns that represents a non-match

Note: This does not use union because that would remove duplicates and not be equivalent to full join.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • ok, but how to do this for like 5 tables? – sg_sg94 Nov 03 '20 at 13:16
  • @sg_sg94 . . . (1) I doubt you really need full joins on five tables. (2) You should ask a new question with sample data, desired results, and an explanation of what you want to accomplish. (3) The answer to the question in your comment is to use CTEs and just add more tables incrementally. – Gordon Linoff Nov 03 '20 at 13:20