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

JS, CSS and HTML to implement the registration page

A registration page template implemented with HTM...

How to set PATH environment variable in Linux system (3 methods)

1. In Windows system, many software installations...

Semantic web pages XHTML semantic markup

Another important aspect of separating structure ...

MySQL 5.7.23 decompression version installation tutorial with pictures and text

It is too troublesome to find the installation tu...

5 commonly used objects in JavaScript

Table of contents 1. JavaScript Objects 1).Array ...

Detailed explanation and extension of ref and reactive in Vue3

Table of contents 1. Ref and reactive 1. reactive...

Gojs implements ant line animation effect

Table of contents 1. Gojs Implementation 1. Drawi...

Detailed explanation of the usage of MySQL data type DECIMAL

MySQL DECIMAL data type is used to store exact nu...

What is this in JavaScript point by point series

Understand this Perhaps you have seen this in oth...

Detailed steps to delete environment variables in Linux

How to delete environment variables in Linux? Use...

How to set default value for datetime type in MySQL

I encountered a problem when modifying the defaul...

Vue implements dynamic routing details

Table of contents 1. Front-end control 1. In the ...