众所周知,枚举值与索引值相关联,因此如果我们在表达式中使用枚举值,那么所有计算都将在索引号上完成。下面的例子将阐明它 -
mysql> Select * from Result; +-----+--------+-------+ | Id | Name | Grade | +-----+--------+-------+ | 100 | Gaurav | GOOD | | 101 | Rahul | POOR | | 102 | Rahul | NULL | | 103 | Mohan | | +-----+--------+-------+ 4 rows in set (0.00 sec) mysql> Select SUM(Grade) from result; +------------+ | SUM(Grade) | +------------+ | 3 | +------------+ 1 row in set (0.00 sec) mysql> Select AVG(Grade) from result; +------------+ | AVG(Grade) | +------------+ | 1 | +------------+ 1 row in set (0.00 sec) mysql> Select Grade+0 from result; +---------+ | Grade+0 | +---------+ | 2 | | 1 | | NULL | | 0 | +---------+ 4 rows in set (0.00 sec) mysql> Select Grade-1 from result; +---------+ | Grade-1 | +---------+ | 1 | | 0 | | NULL | | -1 | +---------+ 4 rows in set (0.00 sec)
以上查询的结果显示了如何在表达式中使用枚举值。
以上是MySQL中的枚举值如何在表达式中使用?的详细内容。更多信息请关注PHP中文网其他相关文章!