Jump to content

[SOLVED] Problem using LIMIT function


garry27

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/129144-solved-problem-using-limit-function/
Share on other sites

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).

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  :o

 

Sometimes it's better to learn the hard way because I will NEVER do that again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.