我有三个表订单,产品和客户订单customer_id和product_id是外键如何在一个查询中获得订单记录的所有列意味着客户名称价格,数量总价
答案 0 :(得分:0)
使用 JOIN
select orders.*, products.*, customers.*
from order as orders
join product as products
on products.id = orders.product_id
join customer as customers
on customers.id = orders.customer_id
答案 1 :(得分:0)
使用Join的一些查询,如下所示
SELECT * FROM product p inner join customer c on p.product_id=c.customer_id inner join order o on p.product_id=o.order_id
或
SELECT customername,price,quantity,totalprice FROM product p inner join customer c on p.product_id=c.customer_id inner join order o on p.product_id=o.order_id