Fetch Records alternatively from database I have following table where each record indicates either start time or end time of a shift for staff.

The first record is for start time, and the next immediate record is for end time.

SELECT * 
FROM  `recorddata` 
ORDER BY  `recorddata`.`Date_Time` ASC 
LIMIT 0 , 30




What i want is all start and end time together as result of query.
Without considering performance, it is possible to solve by using one query with 3 subquery inside.

SELECT * FROM 
   (SELECT * FROM 
       (SELECT id, Date_Time, MOD(@no := @no + 1, 2) AS even 
        FROM recorddata  ORDER BY Date_Time ASC) l
    WHERE even = 0) a, 
   (SELECT id, Date_Time FROM recorddata ORDER BY Date_Time ASC) b
WHERE a.Date_Time &lt; b.Date_Time
GROUP BY a.id