Create a table based on the result of IFNULL : IFNULL « Control Flow Functions « MySQL Tutorial






mysql>
mysql>
mysql> CREATE TABLE tmp SELECT IFNULL(1,'test') AS test;
Query OK, 1 row affected (0.25 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql>
mysql> DESCRIBE tmp;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| test  | varbinary(4) | NO   |     |         |       |
+-------+--------------+------+-----+---------+-------+
1 row in set (0.14 sec)

mysql>
mysql> select * from tmp;
+------+
| test |
+------+
| 1    |
+------+
1 row in set (0.02 sec)

mysql>
mysql> drop table tmp;
Query OK, 0 rows affected (0.01 sec)

mysql>








18.4.IFNULL
18.4.1.IFNULL(expr1,expr2)
18.4.2.Using IFNULL in where clause
18.4.3.Using IFNULL with data in a table
18.4.4.Create a table based on the result of IFNULL
18.4.5.IFNULL() with NULL and NOT NULL value
18.4.6.Use the IFNULL() function to specify a zero in place of the NULL figure