Three uses and differences of MySQL not equal

Three uses and differences of MySQL not equal

Judgment symbols are often used in MySQL, and not equal to is a more commonly used symbol . The following three not equal to symbols are explained

symbol significance
<> The earliest use of inequality is more portable than the following two
!= Later, MySQL added a function similar to the not equal to function in programming languages ​​such as Java.
not in Add data after "not in" to indicate that it is not in the data.

MySQL recommends using <> to indicate inequality . Why? Because of its strong portability and fast query speed . There is a question on LeetCode, which is a movie theater query question. The title is as follows:

insert image description here

In fact, it is very simple. You can query descriptions that are not boring and ids that are not even numbers, and sort the query results using order by. However, when querying descriptions that are not boring, you need to use the not equal to judgment. The following is a comparison of the query time I used three not equal to

insert image description here

It can be seen that <> is still faster, so it is recommended to use <> to indicate inequality.

There is no point in saying more, let’s give an example! ! !

A simple table data:

select * from user where address != "北京" 

select * from user where address <> "Beijing"

select * from user where address = null

select * from user where address is null

select * from user where address != null

Summarize:

select * from user where address != "北京"
 
select * from user where address <> "Beijing"
 
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

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

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

is and is not are used in conjunction with null . I call it is not, not empty.

This concludes this article about the three uses and differences of MySQL not equal. For more relevant MySQL not equal content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of how to write mysql not equal to null and equal to null
  • mysql not equal to symbol writing

<<:  Ten Experiences in Web Design in 2008

>>:  Vue+openlayer5 method to get the coordinates of the current mouse slide

Recommend

Detailed tutorial on Docker pulling Oracle 11g image configuration

Without further ado Start recording docker pullin...

Database query which object contains which field method statement

The database queries which object contains which ...

JS implements dragging the progress bar to change the transparency of elements

What I want to share today is to use native JS to...

Briefly describe the difference between Redis and MySQL

We know that MySQL is a persistent storage, store...

Using CSS3 to create header animation effects

Netease Kanyouxi official website (http://kanyoux...

Detailed explanation of HTML table inline format

Inline format <colgroup>...</colgroup>...

Use of filter() array filter in JS

Table of contents 1. Introduction 2. Introduction...

Example of using #include file in html

There are two files a.htm and b.htm. In the same d...

Introduction to general_log log knowledge points in MySQL

The following operation demonstrations are all ba...

Use of MySQL query rewrite plugin

Query Rewrite Plugin As of MySQL 5.7.6, MySQL Ser...

How to create https using nginx and Tencent Cloud free certificate

I have been studying how to get https. Recently I...

Several principles for website product design reference

The following analysis is about product design pr...

The meaning of status code in HTTP protocol

A status code that indicates a provisional respon...

Example of how to deploy Spring Boot using Docker

Here we mainly use spring-boot out of the box, wh...