问题描述
一个问题要求发生,请假设:
a.ida = b.idb and c.idc = d.idd
and x1.id_i = x2.id_ii
a = 客户
#it 包含所有用餐过的顾客的列表
b = 服务员
#it 包含服务哪些客户的服务员列表
c = 菜单
d = 顺序
#它就像收据一样,上面有详细信息,比如订购了什么以及对服务员的引用
这是我尝试的方法
SELECT x1.param1,x2.param1
FROM customer,waiter,menu,order
LEFT JOIN waiter ON customer.id = waiter.serve_id AS x1
RIGHT JOIN order ON menu.dish_index = order.dish_id AS x2
现在我想对所有x1和x2进行内连接,表顺序包含等于waiter.id的waiter_id,那么有没有办法连接x1和x2? 请帮忙
解决方法
我只会使用 left join
。但你似乎在描述:
from (a left join
b
on <join conditions for a and b>
) join
(d left join
c
on <join conditions on d and c>
)
on <join conditions for inner join>