How can we get alternating even records from MySQL table?

WBOY
Release: 2023-08-24 09:49:36
forward
937 people have browsed it

How can we get alternating even records from MySQL table?

To understand this concept, we will use the data from table'Information'as shown below −

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)
Copy after login

Now, The following query will get alternating even records from the above table "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)
Copy after login

The above is the detailed content of How can we get alternating even records from MySQL table?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!