且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

子查询上的子查询

更新时间:2022-11-27 13:44:53

问题是 JOIN 不完整(详见问题评论).有效的查询是

The issue was an incomplete JOIN (see question comments for details). The query that worked was

select * 
from 
    (
        select c.* 
        from city c 
        where c.Provincecode like 'EC' 
            and c.citycode in
                (
                    select c.citycode 
                    from City c 
                    where SUBSTRING(c.citycode,0,3) not like 'bx'
                )
    ) x 
    INNER JOIN 
    Customers 
        ON Customers.province=x.Provincecode 
            AND Customers.city=x.Citycode 
where Category like 'SC'