Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What comparison operators are there in SQLServer

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

What are the comparison operators in SQLServer? I believe many inexperienced people don't know what to do about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

They act between comparison operators and subqueries, acting like Exists, not exists, in, not in, and other logical meanings, which are also supported by SQLServer2000 but are rarely used. The copy code is as follows: set nocount on use tempdb go if (object_id ('T1') is not null) drop table T1 create table T1 (n int) insert into T1 select 2 union select 3 if (object_id ('T2') is not null) drop table T2 create table T2 (n int) insert into T2 select 1 union select 2 union select 3 union select 4 select * from T2 where n > all (select n from T1)-4 select * from T2 where n > any (select n from T1)- -3 select 4-- select * from T2 where n > some (select n from T1)-- 3 select * from T2 where n = all (select n from T1)-- No data select * from T2 where n = any (select n from T1)-- 2 Magi 3-- select * from T2 where n=some (select n from T1)-- 2 Magi 3 select * from T2 where n

< all (select n from t1 ) --1 select * from t2 where n< any (select n from t1 ) --1,2 --select * from t2 where n=a.n) select * from t2 where n >

All (select n from T1) they are logically similar, but the treatment of null is just the opposite. the first sentence ignores the null of the subquery and finds out the null of T2 at the same time, while the second sentence ignores that the null of T2 cannot be queried at the same time because of the null in T1.

After reading the above, have you mastered any methods to compare operators in SQLServer? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report