A brief discussion on whether MySQL can have a function similar to Oracle's nvl

A brief discussion on whether MySQL can have a function similar to Oracle's nvl

Use ifnull instead of isnull

isnull is used to determine whether it is null. The return value is 1 for null or 0 for not null.

ifnull is equivalent to Oracle's nvl, and is used as follows

mysql> select ifnull(1,10);
+--------------+
| ifnull(1,10) |
+--------------+
| 1 |
+--------------+
1 row in set (0.00 sec)

mysql> select ifnull(null,10);
+-----------------+
| ifnull(null,10) |
+-----------------+
| 10 |
+-----------------+
1 row in set (0.00 sec)


The usage of isnull is as follows

mysql> select isnull(null);
+--------------+
| isnull(null) |
+--------------+
| 1 |
+--------------+
1 row in set (0.00 sec)

mysql> select isnull(1);
+-----------+
| isnull(1) |
+-----------+
| 0 |
+-----------+
1 row in set (0.00 sec)

The above article briefly talks about whether MySQL can have functions similar to Oracle's NVL. This is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Introduction to the use of Oracle's nvl function
  • Detailed explanation of nvl() and nvl2() functions in Oracle

<<:  Linux system disk formatting and manually adding swap partition

>>:  How to create a project with WeChat Mini Program using typescript

Recommend

Three ways to achieve text flashing effect in CSS3 Example code

1. Change the transparency to achieve the gradual...

How to make JavaScript sleep or wait

Table of contents Overview Checking setTimeout() ...

Detailed steps for smooth transition from MySQL to MariaDB

1. Introduction to MariaDB and MySQL 1. Introduct...

Vue implements a draggable tree structure diagram

Table of contents Vue recursive component drag ev...

MySQL 5.7.17 installation and configuration tutorial for Mac

1. Download MySQL Click on the official website d...

Detailed steps to install MySql 5.7.21 in Linux

Preface The most widely used database in Linux is...

MySQL 8.0.18 uses clone plugin to rebuild MGR implementation

Assume that a node in the three-node MGR is abnor...

MySQL 5.7.17 latest installation tutorial with pictures and text

mysql-5.7.17-winx64 is the latest version of MySQ...

How to build Nginx image server with Docker

Preface In general development, images are upload...

Example test MySQL enum type

When developing a project, you will often encount...

Installation tutorial of mysql 5.7 under CentOS 7

1. Download and install the official MySQL Yum Re...

Detailed steps to install Docker 1.8 on CentOS 7

Docker supports running on the following CentOS v...