garry27 Posted October 19, 2008 Share Posted October 19, 2008 I've go this sql I'm using to extract records for a page recordset and it works fine for the first 1-5 records. For the next 6-10 records however, it shows 7 records, and the page after that shows only 2. The total num of records in the database is 13 and running a query without LIMIT confirms this. SELECT * FROM GA_Gig, GA_Town, GA_Venue, GA_User WHERE GA_Gig.townID = GA_Town.townID AND GA_Gig.venueID = GA_Venue.venueID AND GA_Gig.username = GA_User.username AND GA_Town.region = 'North East' ORDER BY GA_Gig.date LIMIT 6,10 Please someone advice me on how I can fix this. Quote Link to comment https://forums.phpfreaks.com/topic/129144-solved-problem-using-limit-function/ Share on other sites More sharing options...
AndyB Posted October 19, 2008 Share Posted October 19, 2008 LIMIT definition: Definition: Limit is used to limit your MySQL query results to those that fall within a specified range. You can use it to show the first X number of results, or to show a range from X - Y results. It is phrased as Limit X, Y and included at the end of your query. X is the starting point (remember the first record is 0) and Y is the duration (how many records to display). Quote Link to comment https://forums.phpfreaks.com/topic/129144-solved-problem-using-limit-function/#findComment-669538 Share on other sites More sharing options...
Maq Posted October 19, 2008 Share Posted October 19, 2008 LIMIT X, Y X=your starting record Y=how many you want to grab FROM X So if you have 13 records and you start from 6 and grab 10 then of course you're going to get 7 more records. What are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/129144-solved-problem-using-limit-function/#findComment-669543 Share on other sites More sharing options...
garry27 Posted October 19, 2008 Author Share Posted October 19, 2008 Oh, right. Silly of me. I thought the second argument was for the record you would want the LIMIT to stop at. Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/129144-solved-problem-using-limit-function/#findComment-669548 Share on other sites More sharing options...
Maq Posted October 19, 2008 Share Posted October 19, 2008 Oh, right. Silly of me. I thought the second argument was for the record you would want the LIMIT to stop at. Many thanks Haha, yeah I did the same thing with a DB at my work. I had a recursive function to incrementally grab records and I kept clogging the server because I was trying to update almost 100,000 records at once Sometimes it's better to learn the hard way because I will NEVER do that again. Quote Link to comment https://forums.phpfreaks.com/topic/129144-solved-problem-using-limit-function/#findComment-669555 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.