How can I create a query equivalent to a left join without actually using left join in SQL?
            Asked
            
        
        
            Active
            
        
            Viewed 2,842 times
        
    -1
            
            
        - 
                    3Possible duplicate of [Simulate a left join without using "left join"](https://stackoverflow.com/questions/9159729/simulate-a-left-join-without-using-left-join) – Ankur Sinha Aug 06 '18 at 09:41
- 
                    INNER JOIN UNION ALL missing rows. – jarlh Aug 06 '18 at 09:43
- 
                    Why would you want to? Do you mean without actually writing "Left join" or that the query plan is without a left join? – Magnus Aug 06 '18 at 09:44
- 
                    Your title & body differ. What is your question? What are definitions of left join & cross join that you understand? What are you able to do? Also, this is a faq, so why did other questions not help? – philipxy Aug 06 '18 at 16:52
- 
                    1Possible duplicate of [LEFT OUTER JOIN EQUIVALENT](https://stackoverflow.com/questions/15572333/left-outer-join-equivalent) – philipxy Aug 06 '18 at 16:56
1 Answers
0
            
            
        You can't easily do it with cross join.  You can do it with an inner join and union all:
select a.*, b.*
from a join
     b 
     on . . .
union all
select a.*, . . .  -- manually put in b columns
from a
where not exists (select 1 from b where . . . );  -- join conditions in the `where` clause
 
    
    
        Gordon Linoff
        
- 1,242,037
- 58
- 646
- 786
