Home > Database > Mysql Tutorial > body text

How to write not equal in mysql

下次还敢
Release: 2024-04-26 04:12:13
Original
643 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!