MySQL IFNULL()控制流运算符的默认返回类型是什么?
实际上,默认的返回类型IFNULL(expression1,expression2)在两个表达式中更为通用,顺序为STRING,REAL或INTEGER。从以下示例可以理解-
示例
mysql> Create table testing Select IFNULL(100,'testing123'); Records: 1 Duplicates: 0 Warnings: 0 mysql> Select * from testing568; +-----------------------+ | IFNULL(100,'testing') | +-----------------------+ | 100 | +-----------------------+ 1 row in set (0.00 sec) mysql> Describe testing568; +-----------------------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------------+------------+------+-----+---------+-------+ | IFNULL(100,'testing') | varchar(7) | NO | | | | +-----------------------+------------+------+-----+---------+-------+ 1 row in set (0.03 sec)
从上面的结果集中可以看出,在这种情况下,列的类型为varchar(7)。换句话说,它是字符串类型。