Home > Database > Mysql Tutorial > body text

How to use not equal in mysql

PHPz
Release: 2023-05-29 18:07:13
forward
2372 people have browsed it

Is not equal in mysql

Is not equal in mysql, , !=, is not It is useless to say more, let’s give an example! ! !

A simple surface data:

How to use not equal in mysql

select * from user where address != "北京"
Copy after login

How to use not equal in mysql

select * from user where address <> "北京"
Copy after login

How to use not equal in mysql

select * from user where address = null
Copy after login

How to use not equal in mysql

select * from user where address is null
Copy after login

How to use not equal in mysql

select * from user where address != null
Copy after login

How to use not equal in mysql

Summary:

select * from user where address != "北京"
 
select * from user where address <> "北京"
 
select * from user where address = null
select * from user where address is null
 
select * from user where address != null
select * from user where address is not null
Copy after login

Just a few sentences, three extremely common points , perhaps we are at a loss when answering, hesitant.

In<>and! = are equivalent. When a certain field is not equal to a certain value (non-empty value), the output result will be that this field is empty and will not be output.

is and is not are used to combine with null, I call it not, not empty

Additional: MySQL query: not equal to Usage method (mysql query is not equal to)

The popular relational database system MySQL provides a set of SQL query statements for obtaining relevant information from the database. Usually, users use SQL to find specific items. In order to get useful results, we need to use comparison operators. If we find something that is not equal to a specific parameter from the database, we can use the "not equal to" operator () operation.

The "not equal to" operator can be used to compare string and numeric values ​​in MySQL. It can be used in the SELECT.. FROM statement and WHERE clause.

The following is an example to demonstrate how to use the inequality operator:

Suppose there is a table called student, a field is name, and there are several rows of records in it..

| name |

|———–|

| John |

| Tom |

| Alex |

| Mark |

To find the records whose name is not equal to Tom from these records, we can use such a query after the where statement:

SELECT * FROM student
WHERE name ‘Tom&#39;;
Copy after login

Run the above query, the result table shows:

| name |

##|———–|

| John |

| Alex |

| Mark |

Finally, it is worth noting that there is also an inequality operator called "!=" in MySQL. The usage is exactly the same as "", so you can use them interchangeably at any time, for example:

SELECT * FROM student
WHERE name != ‘Tom&#39;;
Copy after login
The result is also:

| name |

| ———–|

| John |

| Alex |

| Mark |

The above is the detailed content of How to use not equal in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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