
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we fetch alternate odd 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 odd-numbered records from the above table ‘Information’ −
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)
- Related Articles
- How can we fetch alternate even-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 to fetch the newly added records from a MySQL table?
- How can we fetch a particular row as output 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 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
- How can we remove a column from MySQL table?
- Can we insert records in a MySQL table without auto_increment values?
- How can we fetch month and day from a given date in MySQL?
- How can we delete multiple rows from a MySQL table?
- How can we delete all rows from a MySQL table?

Advertisements