dadamssg87 Posted May 25, 2011 Share Posted May 25, 2011 I have a query that brings up several rows. How do i get it to remove the first row? I know you can LIMIT how many results get brought up but i just want to drop the first one. $query = "Select * FROM Exceptions WHERE hash = '$hash' ORDER BY created DESC"; Quote Link to comment https://forums.phpfreaks.com/topic/237381-remove-first-row-from-query/ Share on other sites More sharing options...
dadamssg87 Posted May 25, 2011 Author Share Posted May 25, 2011 thought of a quick easy fix... <?php $num = 0; foreach($query as $row) { $num++; if($num > 1) { //display all but first row } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/237381-remove-first-row-from-query/#findComment-1219814 Share on other sites More sharing options...
Pikachu2000 Posted May 25, 2011 Share Posted May 25, 2011 This is much better than selecting the entire table to get one record's contents: SELECT * FROM Exceptions WHERE hash = '$hash' ORDER BY created DESC LIMIT 1, 1 Quote Link to comment https://forums.phpfreaks.com/topic/237381-remove-first-row-from-query/#findComment-1219845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.