

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we fetch alternate even-numbered records from MySQL table?
To understand this concept we are using the data from table ‘Information’ as follows −
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)
Now, the query below will fetch the alternate even-numbered 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)
- Related Questions & Answers
- How can we fetch alternate odd numbered records from MySQL table?
- How can we fetch all the records from a particular MySQL table?
- How can fetch records from specific month and year in a MySQL table?
- How can we fetch a particular row as output from a MySQL table?
- How to fetch the newly added records from a MySQL table?
- How can we fetch one or more columns as output from a MySQL table?
- How can we fetch a second highest salary of an employee from a MySQL table?
- Fetch unique records from table in SAP ABAP
- How can we remove a column from MySQL table?
- How can we display all the records from MySQL table with the help of PHP script?
- MySQL query to fetch the latest date from a table with date records
- Can we insert records in a MySQL table without auto_increment values?
- How can we drop UNIQUE constraint from a MySQL table?
- How can we delete multiple rows from a MySQL table?
- How can we delete all rows from a MySQL table?
Advertisements