" or "!=" symbols to express inequality. These two symbols are used to check whether a field is not equal to a specified "value"."/> " or "!=" symbols to express inequality. These two symbols are used to check whether a field is not equal to a specified "value".">

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

How to express not equal in sql

下次还敢
下次还敢Original
2024-04-28 09:27:12714browse

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>

Use !=

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

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>

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!

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
Previous article:Usage of in in sqlNext article:Usage of in in sql