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".
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!