Introduction to MySQL <> and <=> operators

Introduction to MySQL <> and <=> operators

<> Operator

Function: Indicates not equal to.

Note: It has the same function as the “!=” operator, but “<>” is less readable.

### To query non-Han users, the following two statements have the same effect.
> SELECT * FROM user WHERE nation != "汉族";
> SELECT * FROM user WHERE nation <> "Han";

<=> Operator

Function: Safety is equal to

Note: It integrates the functions of the "=" operator and the IS keyword, and can determine both NULL and basic data types. But in comparison, “<=>” is less readable.

From the following SQL statement, we can see that the "=" operator and the IS keyword cannot be used interchangeably. The "=" operator can only determine basic data types, and the IS keyword can only determine NULL.

The "<=>" operator can be used in relatively few scenarios. It can basically only be used for search conditions. There is no need to determine whether a search condition is NULL or a basic data type.

### Query users who have not filled in their gender. The following statements have the same effect> SELECT * FROM user WHERE sex IS NULL;
> SELECT * FROM user WHERE sex <=> NULL;
 
### Query male users. The following statements have the same effect> SELECT * FROM user WHERE sex = "男";
> SELECT * FROM user WHERE sex <=> "male";

This is the end of this article about the MySQL <> and <=> operators. For more related MySQL <> and <=> content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • MYSQL Operator Summary
  • Detailed explanation of the use of MySQL comparison operator regular expression matching REGEXP
  • Summary of the use of special operators in MySql
  • Summary of commonly used operators and functions in MySQL
  • MySQL Notes — SQL Operators

<<:  HTML table markup tutorial (1): Creating a table

>>:  vue+el-upload realizes dynamic upload of multiple files

Recommend

CSS3 transition to implement notification message carousel

Vue version, copy it to the file and use it <t...

How to create a child process in nodejs

Table of contents Introduction Child Process Crea...

Discussion on the numerical limit of the ol element in the html document

Generally speaking, it is unlikely that you will ...

React implements the sample code of Radio component

This article aims to use the clearest structure t...

Analysis of Docker's method for creating local images

The so-called container actually creates a readab...

How to use dl(dt,dd), ul(li), ol(li) in HTML

HTML <dl> Tag #Definition and Usage The <...

Tutorial on using the hyperlink tag in HTML

The various HTML documents of the website are con...

How to generate a free certificate using openssl

1: What is openssl? What is its function? What is...

How to fix some content in a fixed position when scrolling HTML page

This article mainly introduces how some content i...

Pure CSS to achieve click to expand and read the full text function

Note When developing an article display list inte...

How to use the Linux nl command

1. Command Introduction nl (Number of Lines) adds...

A brief discussion on MySQL large table optimization solution

background The amount of new data in the business...

Zabbix configuration DingTalk alarm function implementation code

need Configuring DingTalk alarms in Zabbix is ​​s...

Example code for implementing anti-shake in Vue

Anti-shake: Prevent repeated clicks from triggeri...