为什么这个不在查询中不起作用 [英] why this not in query is not working

查看:71
本文介绍了为什么这个不在查询中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT REGISTRATIONNO FROM VEHICLE_MASTER WHERE REGISTRATIONNO
NOT IN (SELECT REGISTRATIONNO FROM VEHICLE_SUPERUSER where superuserid='demo')



这里的问题是,如果我执行查询时显示的是来自表VEHICLE_MASTER的所有注册号,这是不正确的,


但如果我原谅



the problem here is if i execute the query its displaying all the registration no from the table VEHICLE_MASTER which is incorrect,


but if i exceute the

SELECT REGISTRATIONNO FROM VEHICLE_SUPERUSER where superuserid='demo'


分别显示超级用户标识"demo"的REGISTRATIONNO.

它应仅显示不在"值,但应显示所有值

"not in"关键字无效.

显示我来自VEHICLE_MASTER的所有记录,但存在于VEHICLE_SUPERUSER中的超级用户标识为"demo"的记录除外."


separately its displaying the REGISTRATIONNO of super user id "demo".

it should display the ''not in'' values alone, but its displaying all values

the "not in" keyword is not working.

Show me all the records from VEHICLE_MASTER except for those records that exist in VEHICLE_SUPERUSER where the superuserid is ''demo''"

推荐答案

hi ashok,
您的查询没问题,请检查两个具有相同数据类型的表的REGISTRATIONNO列.仅当同语具有相同的数据类型时,该功能才有效.

例如,让我们说两个表VEHICLE_SUPERUSER和VEHICLE_MASTER中的REGISTRATIONNO int数据类型.检查此内容,希望对您有帮助...

问候,
Sathish
hi ashok,
No problem with your query, check the REGISTRATIONNO column of both the Tables having the same Datatype. Not in works only if the coulmns having the same datatypes.

Let say for ex., REGISTRATIONNO int Datatype in both Tables VEHICLE_SUPERUSER and VEHICLE_MASTER. Check this, Hope its help you...

Regards,
Sathish


使用以下任意一种

Use any of the following

SELECT REGISTRATIONNO FROM VEHICLE_MASTER WHERE 
NOT EXISTS (SELECT REGISTRATIONNO FROM VEHICLE_SUPERUSER where superuserid='demo');

SELECT REGISTRATIONNO FROM VEHICLE_MASTER VM WHERE 
LEFT OUTER JOIN VEHICLE_SUPERUSER VSU ON VM.REGISTRATIONNO = VSU.REGISTRATIONNO WHERE VSU.superuserid != 'demo';


您的查询是

Your query is

SELECT REGISTRATIONNO FROM VEHICLE_MASTER WHERE REGISTRATIONNO
NOT IN (SELECT REGISTRATIONNO FROM VEHICLE_SUPERUSER where superuserid='demo')



所以,你的意思是

显示VEHICLE_MASTER中的所有记录,但超级用户标识为"demo"的VEHICLE_SUPERUSER中存在的记录除外"
按你在这里说的话..



So, what you are saying is

"Show me all the records from VEHICLE_MASTER except for those records that exist in VEHICLE_SUPERUSER where the superuserid is ''demo''"

Going by what you say here..

it should display the ''not in'' values alone, but its displaying all values



..NOT IN语法不是您想要的.如果您只想显示 这些值,则应使用类似
的值



..the NOT IN syntax isn''t what you want. If you want to display only those values, then you should use something like

SELECT 
* 
FROM VEHICLE_MASTER 
WHERE REGISTRATIONNO 
IN (SELECT REGISTRATIONNO FROM VEHICLE_SUPERUSER where superuserid='demo')

>


这篇关于为什么这个不在查询中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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