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

Interactive experience trends that will become mainstream in 2015-2016

The most important interactive design article in ...

Example analysis to fix problems in historical Linux images

Fix for issues with historical Linux images The E...

Recommend some useful learning materials for newbies in web design

Many people also asked me what books I read when ...

Detailed deployment of docker+gitlab+gitlab-runner

environment Server: centos7 Client: window Deploy...

How to install mysql5.6 in docker under ubuntu

1. Install mysql5.6 docker run mysql:5.6 Wait unt...

Use of Linux stat command

1. Command Introduction The stat command is used ...

W3C Tutorial (3): W3C HTML Activities

HTML is a hybrid language used for publishing on ...

Detailed example of jQuery's chain programming style

The implementation principle of chain programming...

MYSQL performance analyzer EXPLAIN usage example analysis

This article uses an example to illustrate the us...