0

您好,我正在尝试编写一个 mysql 查询,该查询根据另一个表中的 id 从一个表中选择多个记录,这是我的查询

SELECT o.total, o.shipping, o.order_date, oc.product_type, oc.quantity, cu.first_name,
cu.last_name, CONCAT(cu.address1, cu.address2) AS address
FROM `orders` AS o 
INNER JOIN order_contents as oc ON o.id=oc.order_id
INNER JOIN `customers` AS cu ON o.customer_id=cu.id
WHERE o.customer_id = '217';

在 order_contents 的内部连接中,如果大于 1,我想选择多个记录

我使用什么样的连接,这可能吗?

4

1 回答 1

1

刚开始从order_contents表中选择

SELECT o.total, o.shipping, o.order_date, oc.product_type, oc.quantity, cu.first_name, cu.last_name, CONCAT(cu.address1, cu.address2) AS address
FROM order_contents AS oc
INNER JOIN `orders` as o ON oc.order_id = o.o_id
INNER JOIN `customers` AS cu ON o.customer_id=cu.id
WHERE o.customer_id = '217';
于 2013-06-05T23:55:23.210 回答