0

Here's sample SQL Full Outer Join code from w3schools:

SELECT column_name
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;

Testing it in online validators (https://www.piliapp.com/mysql-syntax-check/ and https://www.eversql.com/sql-syntax-check-validator/) throws an error:

You have an error in your SQL syntax; it seems the error is around: 'OUTER JOIN table2 ON table1.column_name = table2.column_name' at line 5

w3resource has this sample SQL code:

SELECT * 
FROM table1 
FULL OUTER JOIN table2 
ON table1.column_name=table2.column_name;

Sample code found on SO is pretty much the same code and throws the same error in the validators and on my dev system.

enter image description here

  • Does that make any sense?
  • What is the correct SQL for this?
VikR
  • 4,818
  • 8
  • 51
  • 96

1 Answers1

2

Those query are MSSQL Query not mysql and that two sites are mysql query validator. You don't have FULL JOINS on MySQL, but you can sure emulate them.

sample code to emulate FULL OUTER JOIN on MYSQL :

    SELECT * FROM t1
    LEFT JOIN t2 ON t1.id = t2.id
    UNION ALL
    SELECT * FROM t1
    RIGHT JOIN t2 ON t1.id = t2.id
    WHERE t1.id IS NULL
Mohammad
  • 1,549
  • 1
  • 15
  • 27