Last updated on August 2nd, 2022 at 10:49 am
During and building on yesterday’s blog post about how a query is processed this post will show you how a query processes the Not Equal To operator.
I should start out by saying Not Equal to is also shown with query as “Not (…=…)” or as “!=”. I should also start out by saying that As I explained in my last post, when a query is run it will process each row within a view or a table. Using the following table as our example, let’s look at the how the Not Equal To operator is processed in a query. E.g. this table is comprised of 4 PCs and their add/remove program (ARP) details.
|
PC1 |
PC2 |
PC3 |
PC4 |
1 |
Adobe Reader XI |
Microsoft Project 2010 |
Visio 12 |
Adobe Reader X |
2 |
Visio 12 |
CorelDraw |
ITunes |
Microsoft Project 2010 |
3 |
ITunes |
Office 2010 |
WordStar |
DataStar |
4 |
Microsoft Office 2013 |
|
|
Lotus123 |
5 |
|
|
|
Kix 2010 |
Not Equal To Processing
Equally, don’t forget, we’re trying to find all of the PCs that do not have Microsoft Project 2010 installed.
PC1
1. Firstly, starting at PC1 the query will review each row to look for Microsoft Project 2010.
a. Row 1 is added to the result set since it is != Microsoft Project 2010.
b. Row 2 will be returned due to the face that its is != Microsoft Project 2010.
c. Similarly, Row 3 is also returned since it does note match Microsoft Project 2010.
d. Especially, Row 4 returned to the data set due to its != status.
PC2
2. Afterwards, the process is repeated for PC2.
a. Firstly, Row 2 is != to Microsoft Project 2010 and therefore returned. Even though Row one does equal Project.
b. Further, Row 3 also returned as it also does not equal to Microsoft Project 2010.
PC3
3. Additionally, the process is repeated with PC3.
a. Row 1 is added to the result set since it is != Microsoft Project 2010.
b. Row 2 is added to the result set since it is != Microsoft Project 2010.
c. Row 3 is added to the result set since it is != Microsoft Project 2010.
PC4
4. Lastly, the process is repeated with PC4.
a. Row 1 does not equal Project Either.
b. Row 3 is added to the result set since it is to Microsoft Project 2010.
c. Row 4 is added to the result set since it is to Microsoft Project 2010.
d. Especially, Row 5 returned to the data set due to its != status.
Results
Finally the query will return PC1, PC2, PC3 and PC4 to the result set as each of them has a least one row that is Not Equal To Microsoft Project 2010.
Finally
As you can see above the Not Equal To operator will not give us the results that we are looking for, so in next week’s blog post I will show you the importance of using a subselect query. Additionally, don’t forget that you can subscribe to my RRS feed to stay on top of the latest trips and tricks. Furthermore, if you have any questions about this post, please feel free to contact me @GarthMJ, or leave a note in the comment section below.