youv youv - 5 months ago 16
MySQL Question

How to apply full join in mysql

I need to apply full join in mysql.

My query:-

SELECT * FROM users FULL JOIN userdetails on users.user_id=userdetails.user_id


How can i alter my query to achieve full join

Please help

Answer

If you are lookinf for a full outer join

SELECT * FROM users 
LEFT JOIN userdetails   on users.user_id=userdetails.user_id
UNION 
SELECT * FROM users 
RIGHT JOIN userdetails   on users.user_id=userdetails.user_id
Comments