IFNULL

Sintassi

IFNULL(espr1,espr2)

Descrizione

Se espr1 non è NULL, IFNULL() restituisce espr1; altrimenti restituisce espr2. IFNULL() restituisce un valore numerico o stringa, a seconda del contesto in cui è usato.

Esempi

MariaDB [(none)]> SELECT IFNULL(1,0); 
+-------------+
| IFNULL(1,0) |
+-------------+
|           1 |
+-------------+
1 row in set (0.00 sec)

MariaDB [(none)]> SELECT IFNULL(NULL,10);
+-----------------+
| IFNULL(NULL,10) |
+-----------------+
|              10 |
+-----------------+
1 row in set (0.00 sec)

MariaDB [(none)]> SELECT IFNULL(1/0,10);
+----------------+
| IFNULL(1/0,10) |
+----------------+
|        10.0000 |
+----------------+
1 row in set (0.00 sec)

MariaDB [(none)]> SELECT IFNULL(1/0,'sì');
+-------------------+
| IFNULL(1/0,'yes') |
+-------------------+
| sì                |
+-------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> 

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.