输入banner图图片脚本导航/分类

sqlserver中not in 和 <> 获取为null的数据

 
DECLARE @table TABLE(
 id INT IDENTITY(1,1),
 name VARCHAR(100) null
)

INSERT INTO @table
(
    name
)
SELECT NULL UNION ALL
SELECT ‘aa‘ UNION ALL
SELECT ‘bb‘ UNION ALL
SELECT ‘cc‘


SELECT * FROM @table WHERE name <> ‘aa‘ --取不到null数据

SELECT * FROM @table WHERE ISNULL(name,‘‘) <> ‘aa‘

SELECT * FROM  @table WHERE name NOT IN( ‘aa‘,‘bb‘) --取不到null数据

SELECT * FROM  @table WHERE ISNULL(name,‘‘) NOT IN( ‘aa‘,‘bb‘)

sqlserver中not in 和 <> 获取为null的数据

标签:into   where   ble   table   union all   sel   sql   arch   union