SQL “<>”在 Oracle 中是什么意思

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7646079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 12:20:05  来源:igfitidea点击:

What does "<>" mean in Oracle

sqloracle

提问by Jay

What does <> mean in SQL language: Sample code is as follows

<>在SQL语言中是什么意思:示例代码如下

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;  

回答by Alex Poole

It means 'not equal to'. So you're filtering out records where ordidis 605. Overall you're looking for any records which have the same prodidand qtyvalues as those assigned to ordid605, but which are for a different order.

意思是“不等于”。因此,您要过滤掉ordid605 位置的记录。总的来说,您正在寻找与分配给605 的记录具有相同prodidqty值的任何记录ordid,但它们的顺序不同。

回答by brymck

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 ordidis unique, then it would find exact duplicates.)

此外,对于每个人的信息,这可以返回非零行数。我看到 OP 重新格式化了他的问题,所以它更清楚一些,但据我所知,这会找到产品 ID 在订单 #605 中找到的记录,数量也是如此,但它实际上不是订单 #605。如果订单 #605 包含 1 个苹果、2 个香蕉和 3 个蜡笔,那么如果包含 2 个苹果(但不是 3 个狗),#604 应该匹配。它只是不匹配订单 #605。(如果ordid是唯一的,那么它会找到完全重复的。)

回答by michael667

not equals. See herefor a list of conditions

not equals. 请参阅此处获取条件列表

回答by Arnaud F.

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

它只是意味着“不同的”,某些语言使用!=,其他语言(如 SQL)<>

回答by bwt

I'm surprised nobody mentioned the nullspecial case. I think the meaning of <>is more something like

我很惊讶没有人提到null特殊情况。我认为的意思<>更像是

has a value which is not equal to

有一个不等于的值

In this case it filters out items which have ordid605 anditems which have a nullordid.

在这种情况下,筛选出具有项目ordid605项目其中有一个nullordid

It may be obvious in this context that ordidis never null, but it is never hurts to remember that nullis not<>from 605 (or from anything).

这可能是在这种背景下,明显的ordid是从来没有null的,但它绝不会伤害要记住,null不是<>从605(或任何东西)。

回答by Usman

It means not equal to .

意思是不等于。

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

它与类 C 语言中的 != 相同。但是 <> 是 ISO 标准并且

!= Not equal to (not ISO standard)

!= 不等于(非 ISO 标准)

回答by akhil

It (<>) is a function that is used to compare values in database table.

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.

!=(不等于)功能与 <>(不等于)比较运算符相同。

回答by Jay

It means not equal to

它的意思是 not equal to

Should I use != or <> for not equal in TSQL?

我应该在 TSQL 中使用 != 还是 <> 表示不相等?

Have a look at the link. It has detailed explanation of what to use for what.

看看链接。它详细解释了什么用途。

回答by Lostaunaum

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.

这意味着不等于,这是从查询中排除某些元素的好方法。例如,假设您有一个订单表,然后您在该表中有 OrderStatusID 列。

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

这应该为您提供除已取消订单之外的所有订单!:D

回答by user3181614

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

在mysql扩展版本中,<>给出错误。您正在使用mysql_query最终,您必须使用我的mysql的扩展版本。旧的将在未来的浏览器中被替换。而是使用类似的东西

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

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