[英]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.
记录到批处理表时,我提取product_id并将其存储在批处理表中。 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? 我还如何从批处理表中获取到货日期,有效期,批号和数量?
how can i also get arrival date, expiry date, batch number and quantity from the batch table?
我还如何从批处理表中获取到货日期,有效期,批号和数量?
Add them to the select list. 将它们添加到选择列表。
It is hard to say without seeing table. 不看表就很难说。 I hope this might help you to solve your problem: SQL RIGHT JOIN
我希望这可以帮助您解决问题: SQL RIGHT JOIN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.