MySql COALESCE function usage code example

MySql COALESCE function usage code example

COALESCE is a function that refers to each parameter expression in turn (expression_1, expression_2, ..., expression_n), stops when a non-null value is encountered, and returns the value. If all expressions are null, a null value will be returned. The reason for using COALESCE is that most expressions containing NULL values ​​will eventually return NULL.

Application examples:

SELECT COALESCE (1, 2, 3, 4) as number

SELECT COALESCE (NULL, 2, 3, 4) as number

SELECT COALESCE (NULL, NULL, 3, 4) as number

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Summary of knowledge points related to null (IFNULL, COALESCE and NULLIF) in MySQL
  • Summary of coalesce() usage tips in MySQL
  • Detailed explanation of IFNULL() and COALESCE() functions to replace null in MySQL
  • SQL Server COALESCE Function Detailed Explanation and Examples
  • A brief analysis of the performance comparison between the paging modes ISNULL and COALESCE in SQL Server
  • MySQL time difference functions (TIMESTAMPDIFF, DATEDIFF), date conversion calculation functions (date_add, day, date_format, str_to_date)
  • MySQL uses custom functions to recursively query parent ID or child ID
  • Detailed explanation of the correct use of the if function in MySQL

<<:  Simple use of Vue bus

>>:  Solve the problem of black screen when starting VMware virtual machine

Recommend

Detailed explanation of using echarts map in angular

Table of contents Initialization of echart app-ba...

How to reset the root password of Mysql in Windows if you forget it

My machine environment: Windows 2008 R2 MySQL 5.6...

The marquee tag in HTML achieves seamless scrolling marquee effect

The <marquee> tag is a tag that appears in ...

Detailed explanation of concat related functions in MySQL

1. concat() function Function: Concatenate multip...

Detailed explanation of CSS pre-compiled languages ​​and their differences

1. What is As a markup language, CSS has a relati...

Detailed explanation of :key in VUE v-for

When key is not added to the v-for tag. <!DOCT...

Analysis of problems caused by MySQL case sensitivity

MYSQL is case sensitive Seeing the words is belie...

How to optimize images to improve website performance

Table of contents Overview What is Image Compress...

XHTML tags that are easily confused by the location of the use

<br />We have always emphasized semantics in...

Learn MySQL execution plan

Table of contents 1. Introduction to the Implemen...

Summary of commonly used time, date and conversion functions in Mysql

This article mainly summarizes some commonly used...

Use CSS to implement special logos or graphics

1. Introduction Since pictures take up a lot of s...