`

not in 失效

SQL 
阅读更多

    今天同事碰到一个问题,在做两个表的数据对照时用了not in ,结果出现了查找失败的结果。
网上查了一下才知道,not in 有个毛病:
    像SQL语句  select * from t1 where f1 not in (select f1 from t2) 这是去除t1表中包括t2中数据的语句。
如果在t2中的f1字段中有null值的话,则查不到结果。也就是说在not in 右边的集合中不能有null值,
而在not in左边有null值没有问题。
分享到:
评论
1 楼 vern 2011-11-16  
受益了,谢谢

相关推荐

    mysql面试题大全.docx

    = 或者 ,not in)时,可能会导致索引失效。 • 索引字段上使用is null, is not null,可能导致索引失效。 • 左连接查询或者右连接查询查询关联的字段编码格式不一样,可能导致索引失效。 • mysql估计使用全表...

    唯一非聚集索引变量传入时索引失效解决方案

    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) GO 确认3.执行计划如下: ...

    MySQL数据库经典面试题解析

    = 或者 ,not in)时,可能会导致索引失效。 索引字段上使用is null, is not null,可能导致索引失效。 左连接查询或者右连接查询查询关联的字段编码格式不一样,可能导致索引失效。 mysql估计使用全表扫描要比使用...

    MySQL面试经典100题(收藏版,附答案).doc

    = 或者 ,not in)时,可能会导致索引失效。 索引字段上使用is null, is not null,可能导致索引失效。 左连接查询或者右连接查询查询关联的字段编码格式不一样,可能导致索引失效。 mysql估计使用全表扫描要比...

    Mysql面试过关!(详解:索引+常用引擎+常见问题+sql调优)

    一、Mysql索引 1、添加索引sql语句 2、查看MySQL中建立的索引是否生效 ...3.10 查询条件使用not in、not exists时,如果是主键则走索引,如果是普通索引,则索引失效 3.11 当查询条件涉及到order by、l

    【mysql面试题】100道MySQL数据库经典面试题解析

    = 或者 ,not in)时,可能会导致索引失效。   索引字段上使用is null, is not null,可能导致索引失效。   左连接查询或者右连接查询查询关联的字段编码格式不一样,可能导致索引失效。   mysql估计...

    Javascript中封装window.open解决不兼容问题

    对window.open进行封装, 使其更好用, 且更兼容, 很多人说window.open不兼容,其实不是, 因为不能直接执行, 必须通过用户手动触发才行;看代码: 代码如下 var openWindow = function(url, options) { ...

    使用Element的InfiniteScroll 无限滚动组件报错的解决

    TypeError: Failed to execute ‘observe’ on ‘MutationObserver’: parameter 1 is not of type ‘Node’ InfiniteScroll的更多用法element官网 二、解决办法 给需要使用 InfiniteScroll 的元素或者它的父级...

    Oracle数据库Sql性能调优

    1.20 用NOT EXISTS替代NOT IN 12 1.21 用表连接替换EXISTS 13 1.22 用EXISTS替换DISTINCT 13 1.23 识别’低效执行’的SQL语句 14 1.24 用索引提高效率 14 1.25 索引的操作 15 1.26 多个平等的索引 16 1.27 等式比较...

    MySQL中exists关键字和in的区别有那些? SQL语句优化有那些方法? 查询速度很慢应该怎么办?

    一、exists和in有何区别如下...在索引列上用NOT,等非操作符会导致索引失效,数据库管理系统是不会使用索引的,可以将查询语句转换为可以使用索引的查询。  2. 避免对查询列的操作。任何对查询列的操作都有可能导致全表

    MobaXterm Pro 11.0.3816

    Bugfix: fixed the “live-unpack” mechanism for local terminal plugins – some plugins were not working properly in “installed mode” or when using “persistent root” Bugfix: fixed some issues with ...

    MySql数据库优化之SQL和索引的优化

    索引的优化是面试中数据库部分可以说是必问的...2.2 没有使用联合索引的第一列,not in,!=,使用MySQL函数,类型转换,or等都无法用到索引。 3 SQL和索引的优化 3.1 慢查询日志 3.2 查磁盘的I/O读写的数据量 3.3 sh

    oracle 视图,函数,过程,触发器自动编译脚本

    and a.owner not in ('SYS' ,'SYSTEM','OUTLN','U_SYSTEM'); spool off exit; eof # Start to backup oracle database param echo "-------------- Complete obj compile Started on `date` -------------" >>...

    USB Safely Remove v6.1.5 USB安全删除(简体中文)+破解

    You can setup a program to be launched not only for certain device, but for all hotplug devices in the system One click templates! Dislike reading boring documentation, but interested in one of the ...

    shenfenyanzheng.rar_Unsigned

    id bigint unsigned default 0 not null auto_increment, name varchar (30), password varchar (30), email varchar (30), primary key (id) ) 您想对哪个页面加密,就在页面的头(<html>标签前)加一段...

    Integrated Circuit Failure Analysis: A Guide to Preparation Techniques

    One should not lose sight of the fact that the procedures for removing material in the analysis must work no less precisely than those used in semiconductor manufacturing; this implies high ...

    USBlyzer2.2带破解工具及操作说明

    亲测可以使用,很难找的,试了好多,都不如这个好。 破解不了可以私信联系。

    身份验证程序

    id bigint unsigned default 0 not null auto_increment, name varchar (30), password varchar (30), email varchar (30), primary key (id) ); 您想对哪个页面加密,就在页面的头(标签前)加一段语句,请...

    logisim实验常见问题1

    1. 逻辑门的使用 2. 电路的毛刺很多同学在画电路连线的时候会出现毛刺,即多余的连线,可能因为是手抖或者其他原因,如图2所示 3. 导线连接在逻辑门或者芯片连

    AIAG FMEA 4th Edition

    潜在失效FMEA 4 Edition is a reference manual to be used by suppliers to Chrysler LLC, Ford Motor Company, and General Motors Corporation as a guide to assist them in the development of both Design and...

Global site tag (gtag.js) - Google Analytics