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 表中获取备用奇数记录?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!