I know MySQL full outer join is syntax error. I have a full outer join in mysql5 would like to create a similar query. What do I do?
            Asked
            
        
        
            Active
            
        
            Viewed 131 times
        
    -3
            
            
        - 
                    Use a UNION of a LEFT JOIN and RIGHT JOIN. – Barmar Jul 16 '13 at 10:22
- 
                    Where is the problem? – matino Jul 16 '13 at 10:22
- 
                    Hi and welcome to SO. Unfortunately, your first attempt at asking a question is decidedly flawed. Suggest read the guidelines and amend/start again. – Strawberry Jul 16 '13 at 10:40
1 Answers
0
            
            
        You can emulate FULL OUTER JOIN using UNION (from MySQL 4.0.0 on):
with two tables t1, t2:
SELECT * FROM t1
LEFT JOIN t2 ON t1.id = t2.id
UNION
SELECT * FROM t1
RIGHT JOIN t2 ON t1.id = t2.id
with three tables t1, t2, t3:
SELECT * FROM t1
LEFT JOIN t2 ON t1.id = t2.id
LEFT JOIN t3 ON t2.id = t3.id
UNION
SELECT * FROM t1
RIGHT JOIN t2 ON t1.id = t2.id
LEFT JOIN t3 ON t2.id = t3.id
UNION
SELECT * FROM t1
RIGHT JOIN t2 ON t1.id = t2.id
RIGHT JOIN t3 ON t2.id = t3.id
 
    
    
        Smriti
        
- 1,552
- 3
- 15
- 29
