I'm trying to JOIN two columns from ps_products and one from ps_product_lang into one table in the PrestaShop database with a query, but I can't figure it out.. Whenever I run the code below, I just get NULL values for name, and vice versa when I switch RIGHT and LEFT. I've tried using UNION ALL, putting parenthesis around the SELECT queries and using WHERE, but nothing works.. The database runs MySQL, so FULL OUTER JOIN isn't possible without a workaround. I'm not very experienced in SQL, so I might've missed something here.
The code:
SELECT
ps_product_lang.name AS 'name',
ps_product.id_product AS 'product id',
ps_product.reference AS 'reference'
FROM ps_product_lang
RIGHT JOIN ps_product ON name = reference
UNION
SELECT
ps_product_lang.name AS 'name',
ps_product.id_product AS 'product id',
ps_product.reference AS 'reference'
FROM ps_product_lang
LEFT JOIN ps_product ON name = ps_product.reference
Any idea? Thanks!