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

Native js to achieve simple carousel effect

This article shares the specific code of js to ac...

A brief discussion on the magic of parseInt() in JavaScript

cause The reason for writing this blog is that I ...

Vue's global watermark implementation example

Table of contents 1. Create a watermark Js file 2...

How to display div on object without being blocked by object animation

Today I made a menu button. When you move the mous...

ThingJS particle effects to achieve rain and snow effects with one click

Table of contents 1. Particle Effects 2. Load the...

MySQL SQL statement performance tuning simple example

MySQL SQL statement performance tuning simple exa...

JavaScript Basics Objects

Table of contents 1. Object 1.1 What is an object...

VMware virtual machine installation Apple Mac OS super detailed tutorial

Table of contents Summarize Sometimes we need to ...

Implementation steps for docker-compose to deploy etcd cluster

Table of contents Write docker-compose.yml Run do...

How to install mysql via yum on centos7

1. Check whether MySQL is installed yum list inst...

VMware ESXi installation and use record (with download)

Table of contents 1. Install ESXi 2. Set up ESXi ...

MySQL latest version 8.0.17 decompression version installation tutorial

Personally, I think the decompressed version is e...

CocosCreator implements skill cooling effect

CocosCreator realizes skill CD effect There are s...