简体   繁体   English

sql右联接从右表返回多行

[英]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.

相关问题 SQL左联接-右表中的多行 - SQL Left Join - Multiple Rows in Right Table 右联接不会返回右侧表中的所有记录 - Right Join does not return all the records from right side table 内部联接到右表后,SQL查询从左表中选择不同的行 - SQL query to select distinct rows from left table after inner join to the right table MySQL JOIN:仅返回右表中所有值均为 NULL 的行 - MySQL JOIN: Only return rows where all values from right table are NULL 左外部联接,带选择,其中右表中的值不返回左中的所有行 - Left outer join with select where value in right table does not return all rows from left MySQL左连接右侧多行,如何将左侧的每一行合并为一行(我想要从右侧表中连接的字段)? - MySQL left join with multiple rows on right, how to combine to one row for each on left (with the field I want from the right table concated)? 左连接与来自右表mysql的空行 - left join with empty rows from right table mysql 返回LEFT表中的所有行,即使RIGHT表中没有记录,也返回RIGHT表中的最大到期日期 - Return all rows from LEFT table even no record in RIGHT table and maximum expiry date from RIGHT tables AWS GLUE SQL 与右表中的单行连接 - AWS GLUE SQL join with single row from right table mySQL左连接,右表具有(无行)条件 - mySQL left join with (no rows) condition on right table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM