sql uses of "less than or equal to" & "not greater than"

harryovers picture harryovers · Nov 3, 2011 · Viewed 28.5k times · Source

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?

Answer

ddrace picture ddrace · Nov 3, 2011

<= 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.