Home > Database > SQL > body text

How to write not equal to a certain condition in sql

下次还敢
Release: 2024-04-28 10:42:13
Original
443 people have browsed it

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

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

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!

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!