回2搂select typ,custid from Top_Cust except (select custtype 'typ',custid from Top_User_QX_Cust where uid='李林华')服务器: 消息 156,级别 15,状态 1,行 1 在关键字 'except' 附近有语法错误。
custtype是什么?except sql server是受支持的啊,我用过
好像不支持的,我是sql2000 custtype列名,其实就是和typ对应的
SELECT typ,custid FROM Top_Cust WHERE typ NOT IN (SELECT typ FROM Top_User_QX) AND custid NOT IN (SELECT custid FROM Top_User_QX) ---------------------------------------------------------------------------------------- 一楼的应该就能满足呀!!
自己解决了 select a.typ,a.custid from Top_Cust a left outer join Top_User_QX_Cust b on a.custid=b.custid and a.typ=b.custtype and b.uid='李林华' where b.uid is null 本来看去except挺好的
select typ,custid from Top_Cust except (select custtype as typ,custid from Top_User_QX_Cust where uid='李林华') 这样看看
不灭的传说,你好,不行的 其实 as typ 和'typ' 都一样 估计不支持except
select typ,custid from top_user where not exists (select typ,custid from top_user_qx where top_user_qx.typ=top_user.typ and top_user_qx.custid=top_user)
我的意思是主键的组合不在那里面
不是单个
比如
A数据
typ custid
客户 001
客户 002
客户 003
供应商 001
供应商 002
供应商 003
B数据
typ custid
客户 002
供应商 001那么出来的应该是
typ custid
客户 001
客户 003
供应商 002
供应商 003
在关键字 'except' 附近有语法错误。
custtype列名,其实就是和typ对应的
----------------------------------------------------------------------------------------
一楼的应该就能满足呀!!
我都测试过了
如果数据如下,客户 001不会出来,但是应该出来的
A数据
typ custid
客户 001
客户 002
客户 003
供应商 001
供应商 002
供应商 003
B数据
typ custid
客户 002
供应商 001 那么出来的应该是
typ custid
客户 001
客户 003
供应商 002
供应商 003
select a.typ,a.custid from Top_Cust a
left outer join Top_User_QX_Cust b
on a.custid=b.custid and a.typ=b.custtype and b.uid='李林华'
where b.uid is null
本来看去except挺好的
select typ,custid from Top_Cust except (select custtype as typ,custid from Top_User_QX_Cust where uid='李林华') 这样看看
其实 as typ 和'typ' 都一样
估计不支持except