-2
SELECT 
    emp.id,
    emp.Name,
    dept.name 
FROM employee as emp 
FULL OUTER JOIN department as dept ON emp.dept_id=dept.id
Mark Miller
  • 7,442
  • 2
  • 16
  • 22
Harsh
  • 41
  • 6

1 Answers1

0

Full outer Joins not Works supports on MYSQL, so Support FULL [OUTER] JOIN by rewriting with UNION. Link

 select * from t1 left join t2 on (t1.s1=t2.s1)
 union select * from t1 right join t2 on (t1.s1=t2.s1);

or

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

So the "full join" returns fewer rows than the left join.]

As a full outer join can't be optimized much anyway, the above appears to be a pretty decent solution.

If the joined fields are indexed, we could utilize a method similar to our new "merge index" optimisation to intersect the two indexes and optimize the operation that way.

InventorX
  • 423
  • 2
  • 7