What I love most about my job Comprehensive Database Performance Health Check, is that I get to work with different people and answer questions. Today we will see a very interesting question – Are Not Equal (<> or !=! to Operators Equal to Not In?
To be honest the question was very interesting and I built a very simple video of SQL in the Sixty Seconds on it. Please watch the video and do let me know your feedback about it.
Here is a simple demonstration of the sample database WideWorldImporters. Here is the instruction to download them. I am sure the video gave you the required answer. Now let me share the script which I had used in the video.
USE WideWorldImporters GO SET STATISTICS IO ON; SELECT DISTINCT LastEditedBy FROM [Sales].[Orders] WHERE LastEditedBy <> 7 AND LastEditedBy <> 15 GO SELECT DISTINCT LastEditedBy FROM [Sales].[Orders] WHERE LastEditedBy != 7 AND LastEditedBy != 15 GO SELECT DISTINCT LastEditedBy FROM [Sales].[Orders] WHERE LastEditedBy NOT IN (7,15) GO
Here are links to the last seven videos which I have built in the SQL in the Sixty Seconds series besides today topic of operators equal.
- Negative Identity Column – SQL in Sixty Seconds #101
- Patch Your SQL Server – SQL in Sixty Seconds #100
- Keyword Join or Inner Join – SQL in Sixty Seconds #099
- List All Parallel Queries – SQL in Sixty Seconds #098
- Alter Index Add Column – Workaround – SQL in Sixty Seconds #097
You can follow my SQL in Sixty Seconds series on YouTube over here.
Reference: Pinal Dave (https://blog.sqlauthority.com)
1 Comment. Leave new
while and != are the same, the first is ANSI/ISO Standard SQL and the second is dialect taken from C family programming languages. When I see it, know that the programmer does not speak SQL, so I can predict his errors.