外联接查询条件顺序的对查询结果的影响
外连接查询条件顺序的对查询结果的影响select c.name_check_state, a.no_bill, from ls_requisition_2 as
外连接查询条件顺序的对查询结果的影响
select
c.name_check_state,
a.no_bill,
from
ls_requisition_2 as b
left join
ls_requisition_1 as a on a.no_bill = b.no_body
left join
ls_item as c on c.no_ls = b.no_item;
select
c.name_check_state,
a.no_bill,
from
ls_requisition_2 as b
left join
ls_requisition_1 as a on b.no_body = a.no_bill
left join
ls_item as c on b.no_item = c.no_ls;
我想知道我的a,no_bill = b.no_body 顺序反一下有什么区别啊 就是因为我顺序写反了所以结果没查询出来
是不是我把如果我把left join改成right join 是不是不用换顺序也可以呢 外连接
[解决办法]from a (left/right/full) join b on xxxx
(left/right/full) join c on xxxx
它的执行顺序是先a与b关联,然后生成一个虚拟表假设叫做D,然后d与c再关联,本身你的顺序是没有太大影响,但是你在on中这样调换,需要了解你的表里面是否有符合条件的数据,这属于逻辑问题,不是写法问题。