為了理解這個概念,我們使用表格「資訊」中的數據,如下-
mysql> Select * from Information; +----+---------+ | id | Name | +----+---------+ | 1 | Gaurav | | 2 | Ram | | 3 | Rahul | | 4 | Aarav | | 5 | Aryan | | 6 | Krishan | +----+---------+ 6 rows in set (0.00 sec)
現在,下面的查詢將從上面的「資訊」表中取得備用奇數記錄-
mysql> Select id,Name from information group by id having mod(id,2) = 1; +----+--------+ | id | Name | +----+--------+ | 1 | Gaurav | | 3 | Rahul | | 5 | Aryan | +----+--------+ 3 rows in set (0.09 sec)#
以上是我們如何從 MySQL 表中取得備用奇數記錄?的詳細內容。更多資訊請關注PHP中文網其他相關文章!