[sql] What does "<>" mean in 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;  

This question is related to sql oracle

The answer is


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


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


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


not equals. See here for a list of conditions


It means not equal to .

It's the same as != in C-like languages. but <> is ISO Standard and

!= Not equal to (not ISO standard)


In mysql extended version, <> gives out error. You are using mysql_query Eventually, you have to use extended version of my mysql. Old will be replaced in future browser. Rather use something like

$con = mysqli_connect("host", "username", "password", "databaseName");

mysqli_query($con, "select orderid != 650");

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