Home  >  Article  >  Database  >  How to write not equal in mysql

How to write not equal in mysql

下次还敢
下次还敢Original
2024-04-26 04:12:13749browse

MySQL There are two ways to write inequalities: the inequality sign (<>) and the inequality keyword (NOT EQUAL TO). The two writing methods have the same function. You can use <> to compare whether two values ​​are not equal, such as: SELECT FROM table_name WHERE column_name <> value; you can also use NOT EQUAL TO, such as: SELECT FROM table_name WHERE column_name NOT EQUAL TO value.

How to write not equal in mysql

How to write the inequality operator in MySQL

There are two ways to write the inequality operator in MySQL:

  1. Not equal to: <>

For example:

SELECT * FROM table_name WHERE column_name &lt ;> value;

  1. Not equal to keywords: NOT EQUAL TO

For example:

SELECT * FROM table_name WHERE column_name NOT EQUAL TO value;

These two writing methods have the same function and can be used to compare whether two values ​​are not equal.

Example

The following query finds all records in the table_name table where column_name is not equal to value :

<code class="sql">SELECT * FROM table_name WHERE column_name <> value;</code>

The following query finds all records in the table_name table where column_name is not equal to value:

<code class="sql">SELECT * FROM table_name WHERE column_name NOT EQUAL TO value;</code>

Note:

Unlike other relational database management systems (such as Oracle), MySQL does not support the != operator.

The above is the detailed content of How to write not equal in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn