Differences between the <> and the NOT-operator

Although the <> and the NOT search operators may appear to be very similar, it actually are two different operators that behave differently. The purpose of this blog is to explain those differences.

In the simplest scenario (when searching using a specific property of an object) both operators will return the same result. For example, to search for all users that have a name other than John Doe, you can use any of the following search expressions:

  • Name <> "John Doe"
  • NOT (Name = "John Doe")

In this scenario, the difference is minimal since both search expression return the same result. However, the performance of the <> operator will be better than that of the NOT-operator, so in this we prefer the <> operator.

However, the differences become much more apparant when querying more complex objects. When searching for records, the following two search expressions for example will return a different result:

  • File.Version.Filename <> test.jpg
  • NOT (File.Version.Filename = test.jpg)

The first search expression (using the <> operator) will return all records that contain at least one file version with a filename other than test.jpg. The second search expression (using the NOT operator) will return all records that don't contain any file named test.jpg.

As long as the record only has one file and this file only has one version, the result of both search expressions will be the same. However, suppose a particular record contains two files. One called test.jpg and one called helloworld.jpg. This particular record is one that would be returned by the search expression using the <> operator because it will find a match in the other file. This record would not be returned by the search expression using the NOT operator however.

So, although both operators may appear to be equivalent, there are suddle differences between the two that you need to be aware of.

Comments

Leave a comment
You must be logged in to post comments.
Sign in now
 
 
Technical
Business
rss feed