Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "<>" mean in Oracle

Tags:

sql

oracle

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;  
like image 593
Jay Avatar asked Oct 04 '11 09:10

Jay


People also ask

Is != and <> same in SQL?

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 vs <> in Oracle?

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.

Is it better to use <> or != In SQL?

Both are valid, but '<>' is the SQL-92 standard.


3 Answers

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

like image 34
brymck Avatar answered Oct 04 '22 23:10

brymck


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.

like image 73
Alex Poole Avatar answered Oct 04 '22 22:10

Alex Poole


It just means "different of", some languages uses !=, others (like SQL) <>

like image 21
Arnaud F. Avatar answered Oct 05 '22 00:10

Arnaud F.