Search code examples
mysqljoinright-join

sql right join return multiple rows from right table


I have two tables products table and batch table. products table contains a list of products and batch table contains information on arrival date, expiry date, batch number and quantity. when recording to batch table i pull product_id and store it on batch table. I want to query the two tables using right join, however I am not able to get the other rows from the batch table. here is my code

SELECT products.product_id, products.gen_name,products.product_code, batch.product_id FROM products RIGHT OUTER JOIN batch ON batch.product_id=products.product_id;

how can i also get arrival date, expiry date, batch number and quantity from the batch table?


Solution

  • It is hard to say without seeing table. I hope this might help you to solve your problem: SQL RIGHT JOIN