What does <> mean in SQL language: Sample code is as follows
SELECT ordid,
prodid,
qty
FROM item
WHERE prodid IN (SELECT prodid
FROM item
WHERE ordid = 605)
AND qty IN (SELECT qty
FROM item
WHERE ordid = 605)
AND ordid <> 605;
If != and <> both are the same, which one should be used in SQL queries? Here is the answer – You can use either != or <> both in your queries as both technically same but I prefer to use <> as that is SQL-92 standard.
Is not null determines if the object/record being inspected is a true null value or not (no data). <> '' means is not an empty string, so the record does contain data (that there is an empty string) and is not actually null. So a query with is not null will return records with a value of string.
Both are valid, but '<>' is the SQL-92 standard.
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.)
It means 'not equal to'. So you're filtering out records where ordid
is 605. Overall you're looking for any records which have the same prodid
and qty
values as those assigned to ordid
605, but which are for a different order.
It just means "different of", some languages uses !=
, others (like SQL) <>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With