Mega Code Archive

 
Categories / MySQL Tutorial / Control Flow Functions
 

Create a table based on the result of IFNULL

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>