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

How to write not equal in sql

下次还敢
下次还敢Original
2024-05-01 23:36:13934browse

The inequality symbol in SQL is <>, which is used to express inequality. Other inequality operators include != (equivalent to <>) and NOT IN (checks whether a value does not belong to a set of values).

How to write not equal in sql

Inequality symbol in SQL

In SQL, the symbol used to express inequality is <>.

Usage Example

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

In this example, the <> notation will return all column_name not equal to value rows.

Other inequality operators

In addition to the <> symbol, there are other inequality operators in SQL:

  • !=: Equivalent to <>
  • NOT IN: Checks whether the value does not belong to a Group Value

Example

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

SELECT * FROM table_name
WHERE column_name NOT IN ('value1', 'value2', 'value3');</code>

The above is the detailed content of How to write 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