我们如何从MySQL表中获取交替的偶数记录?

WBOY
WBOY 转载
2023-08-24 09:49:36 687浏览

我们如何从MySQL表中获取交替的偶数记录?

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)

现在,下面的查询将从上述表格“Information”中获取交替的偶数记录 −

mysql> Select id,Name from information group by id having mod(id,2) = 0;
+----+---------+
| id | Name    |
+----+---------+
|  2 | Ram     |
|  4 | Aarav   |
|  6 | Krishan |
+----+---------+
3 rows in set (0.00 sec)

以上就是我们如何从MySQL表中获取交替的偶数记录?的详细内容,更多请关注php中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除