当前位置: 代码迷 >> Sql Server >> 这句SQL语句该如何写才对
  详细解决方案

这句SQL语句该如何写才对

热度:43   发布时间:2016-04-27 17:24:43.0
这句SQL语句该怎么写才对?
select uid from [user] where uid not in ((select uid from ainfo) 加 (select uid from binfo) 加 (select uid from cinfo) )

意思就是选出没有发布过信息的会员
从三个信息表的结果进行匹配
not in后面的就不知道该怎么描述了,就是选择出三个表里的会员并相加起来供前面的[user]表的uid进行匹配 

这句SQL应该怎么写

------解决方案--------------------
select uid from [user] where uid not in 
(
(select uid from ainfo) 
union
(select uid from binfo) 
union
(select uid from cinfo) 
)
------解决方案--------------------
SQL code
select U.uid from [user] U left join ainfo A ON U.uid=A.uidleft join binfo B ON U.uid=B.uidleft join cinfo C ON U.uid=C.uidwhere A.uid is null ANDB.uid is null ANDC.uid is null
  相关解决方案