Take the 2-minute tour ×

Why are there two different logical operators that seem to do the same thing (<= & !>), is there any situation where one would be prefered over the other?

share|improve this question
Personally, I've NEVER seen !> used anywhere, in any language. Is that valid syntax somewhere? –  Marc B Nov 3 '11 at 17:42
No. When a RDBMS has both, they are equivalent. –  ypercube Nov 3 '11 at 17:43
+1 Just because I had no idea SQL Server supported that. –  Martin Smith Nov 3 '11 at 17:45
The !=, !< and !> are not standard if I remember well and are only supported by few systems. –  ypercube Nov 3 '11 at 17:45
show 2 more comments

5 Answers

up vote 5 down vote accepted

<= and > are comparison operators, not logical operators. ! is a logical operator (means NOT). When you combine ! and >, you're simply inverting a comparison operator, so your end result is the same.

Having said that, <= is the common form, so I'd say it's preferred, for readability if nothing else. I don't know if there's a performance benefit to either, but I doubt it.

Edit: Also, you didn't say which flavor of SQL you're dealing with. As @harryovers pointed out, that's a valid operator in MS-SQL, but it might not work everywhere.

share|improve this answer
For reference: beginner-sql-tutorial.com/sql-operators.htm –  ddrace Nov 3 '11 at 17:47
add comment

I can't see why you would use one over the other, but !> is not in ISO standards, and based on that I would say that <= is the preferred way.

share|improve this answer
add comment

No, there's no difference. Only reason I can think of is to make it more human-readable in a certain context.

E.g. for the same reason I'd use < 5 rather than <= 4 if there was a significance to the 5 representing some limit in the context.

share|improve this answer
add comment

The !=, !< and !> are not standard comparison operators and are only supported by few systems, SQL-Server being one: msdn: Comparison Operators (Transact-SQL). MySQL also supports != but only that, not the other two.

The equivalent standard SQL comparison operators are <>, >= and <=.

In all situations, I would prefer the standard. You don't know when you have to migrate your code to another platform (and have less errors to deal with.)

share|improve this answer
add comment

When you say logical operators logical is AND and OR I've never seen !> I've seen <>

If you are referring to != and <> they are the same.

share|improve this answer
Never used it...strange never knew that would even work. Still it doesn't change how it works, just a different way to skin a cat I guess. –  JonH Nov 3 '11 at 17:47
add comment

Your Answer


