MySQL mysql查询中<>是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39075213/
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-08-31 21:58:53  来源:igfitidea点击:

What is the meaning of <> in mysql query?

mysqlsql

提问by Manoj venk

I have a MySQL query that includes <> in it. I don't know the exact usage of it.

我有一个包含 <> 的 MySQL 查询。我不知道它的确切用法。

SELECT * FROM table_laef WHERE id = ? AND genre_type <> 'LIVE'

P.S.: Im sorry for this basic syntax, since I have searched for this on Google. All they give is about <=>. Thanks anyway, guys!

PS:我很抱歉这个基本语法,因为我在谷歌上搜索过这个。他们所提供的只是关于<=>。无论如何,谢谢,伙计们!

回答by juergen d

<>is standard ANSI SQLand stands for not equalor !=.

<>是标准的ANSI SQL,代表不等于!=

回答by Reece Kenney

<>means not equal to, !=also means not equal to.

<>表示不等于!=也表示不等于。

Documentation

文档

回答by Raman Sahasi

In MySQL, <>means Not Equal To, just like !=.

在 MySQL 中,<>表示Not Equal To,就像!=.

mysql> SELECT '.01' <> '0.01';
        -> 1
mysql> SELECT .01 <> '0.01';
        -> 0
mysql> SELECT 'zapp' <> 'zappp';
        -> 1

see the docsfor more info

查看文档了解更多信息

回答by Bear Nithi

<>means NOT EQUAL TO, !=also means NOT EQUAL TO. It's just another syntactic sugar. both <>and !=are same.

<>意味着不等于!=也意味着不等于。这只是另一种语法糖。这两个<>!=是一样的。

The below two examples are doing the same thing. Query publisher table to bring results which are NOT EQUAL TO <> !=USA.

下面的两个例子正在做同样的事情。查询发布者表以带来不等于<> !=美国的结果。

SELECT pub_name,country,pub_city,estd FROM publisher WHERE country <> "USA";

SELECT pub_name,country,pub_city,estd FROM publisher WHERE country <> "USA";

SELECT pub_name,country,pub_city,estd FROM publisher WHERE country != "USA";

SELECT pub_name,country,pub_city,estd FROM publisher WHERE country != "USA";

回答by user1751658

In MySQL, I use <>to preferentially place specific rows at the front of a sort request.

在 MySQL 中,我使用<>优先将特定行放在排序请求的前面。

For instance, under the column topic, I have the classifications of 'Chair', 'Metabolomics', 'Proteomics', and 'Endocrine'. I always want to list any individual(s) with the topic 'Chair', first, and then list the other members in alphabetical order based on their topicand then their name_last.

例如,在列下topic,我有“椅子”、“代谢组学”、“蛋白质组学”和“内分泌”的分类。我总是想首先列出主题为“主席”的任何个人,然后根据他们的字母顺序列出其他成员topic,然后是他们的name_last.

I do this with:

我这样做:

SELECT scicom_list ORDER BY topic <> 'Chair',topic,name_last;

This outputs the rows in the order of:
Chair
Endocrine
Metabolomics
Proteomics

这将按以下顺序输出行:
Chair
Endocrine
Metabolomics
Proteomics

Notice that topic <> 'Chair'is used to select all the rows with 'Chair' first. It then sorts the rows where topic = Chairby name_last.*

请注意,topic <> 'Chair'它用于首先选择带有“椅子”的所有行。然后topic = Chairname_last.*对行进行排序

*This is a bit counterintuitive since <>equals !=based on other feedback in this post.

*这有点违反直觉,因为<>等于!=基于本文中的其他反馈。

This syntax can also be used to prioritize multiple categories. For instance, if I want to have "Chair" and then "Vice Chair" listed before the rest of the topics, I use the following

此语法还可用于确定多个类别的优先级。例如,如果我想在其余主题之前列出“主席”和“副主席”,我使用以下

SELECT scicom_list ORDER BY topic <> 'Chair',topic <> 'Vice Chair',topic,name_last;

This outputs the rows in the order of:
Chair
Vice Chair
Endocrine
Metabolomics
Proteomics

这将按以下顺序输出行:
主席
副主席
内分泌
代谢
组学蛋白质组学

回答by Arun Kumar N

<>is equal to !=i.e, both are used to represent the NOT EQUAL operation. For instance, email <> ''and email != ''are same.

<>等于!=即,两者都用于表示 NOT EQUAL 运算。例如,email <> ''email != ''是一样的。