What does <> mean in SQL language: Sample code is as follows
SELECT ordid,
prodid,
qty
FROM item
WHERE prodid IN (SELECT prodid
It means not equal to
Should I use != or <> for not equal in TSQL?
Have a look at the link. It has detailed explanation of what to use for what.
It just means "different of", some languages uses !=
, others (like SQL) <>
It (<>) is a function that is used to compare values in database table.
!= (Not equal to) functions the same as the <> (Not equal to) comparison operator.
I'm surprised nobody mentioned the null
special case. I think the meaning of <>
is more something like
has a value which is not equal to
In this case it filters out items which have ordid
605 and items which have a null
ordid
.
It may be obvious in this context that ordid
is never null
, but it is never hurts to remember that null
is not <>
from 605 (or from anything).
It means not equal to, this is a good method to exclude certain elements from your query. For example lets say you have an orders tables and then you have OrderStatusID column within that table.
You also have a status table where
0 = OnHold,
1 = Processing,
2 = WaitingPayment,
3 = Shipped,
4 = Canceled.
You can run a query where
Select * From [Orders] where OrderStatusID <> 4
this should give you all the orders except those that have been canceled! :D
Does not equal. The opposite of =
, equivalent to !=
.
Also, for everyone's info, this can return a non-zero number of rows. I see the OP has reformatted his question so it's a bit clearer, but as far as I can tell, this finds records where product ID is among those found in order #605, as is quantity, but it's not actually order #605. If order #605 contains 1 apple, 2 bananas and 3 crayons, #604 should match if it contains 2 apples (but not 3 dogs). It just won't match order #605. (And if ordid
is unique, then it would find exact duplicates.)