如何使用不在两个属性的子句? [英] how to use not in clause fro two attributes ?

查看:67
本文介绍了如何使用不在两个属性的子句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在两个属性中使用not in子句?









select * from table1 where(std and isd )不在



(从表2中选择std,isd)

how to use not in clause fro two attributes ?

like


select * from table1 where (std and isd) not in

(Select std,isd from Table2)

推荐答案

试试这个:

如果std和isd是varchar

Try this:
if the std and isd are varchar
select * from table1 where (std + isd) not in
(Select std + isd from Table2) 



else


else

select * from table1 where (CONVERT(varchar, std)  + CONVERT(varchar, isd)) not in
(Select (CONVERT(varchar, std)  + CONVERT(varchar, isd)) from Table2)





另一种方法是使用不存在



Another way is to use not exists

select * from table1 where not exists
(Select * from Table2 where table2.std=table1.std and table2.isd=table1.isd)


这篇关于如何使用不在两个属性的子句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆