Home  >  Article  >  Database  >  How to write not equal to a certain condition in sql

How to write not equal to a certain condition in sql

下次还敢
下次还敢Original
2024-04-28 10:42:13448browse

The <> operator is used in SQL to indicate that it is not equal to a certain condition. The example is as follows: SELECT * FROM table_name WHERE column_name <> 'value';

How to write not equal to a certain condition in sql

How to express not equal to a certain condition in SQL

In SQL, use the <> operator to express not equal to a certain condition conditions. <> Operator indicates that two expressions are not equal.

Example:

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

This query will select all columns from the table_name table that satisfy the column_name column not equal to value The row of the condition.

Other operators:

In addition to the <> operator, there are other operators that can be used to compare values. These include:

  • ##=: equal to
  • !=: not equal to
  • <: less than
  • >: greater than
  • <=: less than or equal to
  • >= : Greater than or equal to

Examples using these operators:

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

The above is the detailed content of How to write not equal to a certain condition 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 all in sqlNext article:Usage of all in sql