SQL的IN, SOME,ANY,IN

表dbo.Student有12条数据

name

123123
123123
123123
123123
123123
123123
大雄1
阿华
浩然
菊花
大姐
123123

 

1.some,any用法一样(不知道有没有其他的不同)

select COUNT(*) from dbo.Student
where '123' = some(select Name from Student)

where 判断不含有等于'123'的字段,该条语句返回0.

2.all

select COUNT(*) from dbo.Student
where '123123' <> all(select Name from Student)

where判断123123不等于所有的Name,该条语句返回0.

3.In /NO IN

select COUNT(*) from dbo.Student
where '123' in (select Name from Student)

where 判断含有等于'123'的字段,该条语句返回0.

select COUNT(*) from dbo.Student
where '123' not in (select Name from Student)

where 判断不含有等于'123'的字段,该条语句返回0.

你可能感兴趣的:(sql)