眾所周知,枚舉值與索引值相關聯,因此如果我們在表達式中使用枚舉值,那麼所有計算都會在索引號碼上完成。下面的範例將闡明它 -
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中文網其他相關文章!