Home > Database > SQL > How to express not equal in sql

How to express not equal in sql

下次还敢
Release: 2024-04-28 09:27:12
Original
784 people have browsed it

You can use "<>" or "!=" symbols in SQL to indicate inequality. These two symbols are used to check whether a field is not equal to a specified "value".

How to express not equal in sql

In SQL, it means not equal

In SQL, not equal can use "<>" or "!=" symbol indicates.

Use<>

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

Use !=

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

Both symbols can be used to check fields Is not equal to the specified "value".

Example

In the following example, we use the "<>" symbol to query all records in the "customers" table where the "age" field is not equal to 30:

<code class="sql">SELECT * FROM customers WHERE age <> 30;</code>
Copy after login

If the "customers" table has the following data:

id name age
1 John 30
2 Mary 25
3 Bob 35
4 Alice 28

Then the above query will return the following results:

id name age
2 Mary 25
4 Alice 28

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

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template