奇怪的问题。 select count(*)from [192.168.0.105].asmis.dbo.gbitem a where a.item_no not in ( select item_no from hgbitem)是多少? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 奇怪.如果只计数,结果是否一样?1。select count(*)from [192.168.0.105].asmis.dbo.gbitem a where a.item_no not in ( select item_no from hgbitem)2。select count(*)from [192.168.0.105].asmis.dbo.gbitem a where a.item_no not in ( select item_no from hgbitem) 用Exists吧,not in我也碰到过莫名奇妙的问题。 然后保证服务器上没有NOT IN 条件里的表最好是都写清楚,省的麻烦 回2楼,是39220,就是问题中第2个sql语句执行结果影响的行数。回3楼,你给的两个sql语句是一模一样的,结果也当然是一样的都是39220。回4楼,上述sql语句如何转化成用exists表示呢,请教。 回5楼,两条语句我放在一起执行的,在同一台电脑上执行。“然后保证服务器上没有NOT IN 条件里的表最好是都写清楚,省的麻烦”能说详细点吗? 下面的问题更邪门了:select *into #t1from [192.168.0.105].asmis.dbo.gbitem a where a.item_no not in ( select item_no from hgbitem) select * from hgbitemwhere item_no in ( select item_no from #t1)drop table #t1我执行后居然检索出300多条记录,而且这些记录在hgbitem表中跟本就不存在!!结果集为空才对啊! 检查是否数据库有问题:DBCC CHECKDB('数据库名') CHECKDB found 0 allocation errors and 0 consistency errors in database 'tax'. 那真是怪了a.item_noitem_no是否有null记录 你的表中,有没有在item_no上建立索引,如果有的话,试试重建索引:DBCC DBREINDEX ('数据库名.dbo.表名') 你在hgbitem前也加上“机器名.数据库.dbo”试试 item_no在gbitem表和hgbitem表中均是主键,是索引了,也不可能有null值。我也查了确实没null值。风云的方法我先试一下。谢谢这么多热心的高手指点,小弟感激不尽。 试了一下风云的方法,还是不行,但我在item_no前加rtrim结果集就由39220行变成1169行了,难道非得加个rtrim吗?这样做速度慢的惊人! 这样得出的结果有否区别:1。select a.*...2。select a.item_no... 不显示某字段为空的列 存储过程报语法错误,求救。。。 接着学习! 再请问一个SQL语句 刚刚得到解决的交叉表问题,自己加了日期范围条件,报错从字符串转换为datetime 时发生语法错误 SQL销售日报表分组排序问题,请高手指导,谢谢。。。 PB如何实现数据逐级汇总 SQL语句求助 如何分析如下情况数据库查询的速度问题? 今日是mimi生日,我写了一个存储过程祝她生日快乐。 delphi 编的程序,连接的数据库是sql server,连接数据库后,delphi执行存储过程时出错 高手请进,怎样合并字符串???????????????? sql语句怎么把字段再设为默认的null空字段呢?
from [192.168.0.105].asmis.dbo.gbitem a where a.item_no not in ( select item_no from hgbitem)2。select count(*)
from [192.168.0.105].asmis.dbo.gbitem a where a.item_no not in ( select item_no from hgbitem)
最好是都写清楚,省的麻烦
回3楼,你给的两个sql语句是一模一样的,结果也当然是一样的都是39220。
回4楼,上述sql语句如何转化成用exists表示呢,请教。
“然后保证服务器上没有NOT IN 条件里的表
最好是都写清楚,省的麻烦”能说详细点吗?
select *
into #t1
from [192.168.0.105].asmis.dbo.gbitem a where a.item_no not in ( select item_no from hgbitem)
select * from hgbitem
where item_no in ( select item_no from #t1)
drop table #t1我执行后居然检索出300多条记录,而且这些记录在hgbitem表中跟本就不存在!!
结果集为空才对啊!
item_no是否有null记录
风云的方法我先试一下。
谢谢这么多热心的高手指点,小弟感激不尽。
难道非得加个rtrim吗?这样做速度慢的惊人!
1。select a.*
...
2。select a.item_no
...