我有三张A,B,C表。
我如何一次加入A和B以及B加C?
例如,如果我有这些表:订单,产品,用户,我想要这样的查询:
SELECT Product.title, User.username, Order.id
FROM Order
/* with this condition: */
Order.ProductID = Product.ID
Product.UserID = User.ID
答案 0 :(得分:1)
在from子句中组合联接:
select *
from aaa a inner join bbb b
on a.x = b.y
inner join ccc c
on b.x = c.y
答案 1 :(得分:1)
尝试:
SELECT Product.title, User.username, Order.id
FROM Order
INNER join Product ON Order.ProductID = Product.ID
INNER JOIN user ON Product.UserID = User.ID
答案 2 :(得分:0)
select * from A a join B a on a.id = b.id /* condition for join*/ join C c on A.id = c.id /* condition for join*/ where ;//condition