SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Hiding from the world
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using the limit function - doesnt seem to have an effect on my query

    Hi,
    i have a enewsletter list with 6000 email addresses. I want to write a query to send a batch of say 2500 each rather than all at the same time. Ive been trying to use the Limit function but it is not behaving as expected.

    if i do this

    SELECT * from subscribers WHERE active='1' LIMIT 0,2500"

    it returns the first 2500. but when i do another query below it

    SELECT * from subscribers WHERE active='1' LIMIT 2500, 5000"

    it returns all of the results from 2500 to the full 6000. Why is it not stopping at 5000?

    any help appreciated
    If i am a product of your imagination you should try harder!

  2. #2
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    Hiding from the world
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    duh... just realised that the second number in LIMIT is how many to display starting from the first number. NOT where it should stop as i had been thinking.

    hence it was displaying 5000 records starting at 2500.
    If i am a product of your imagination you should try harder!

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,323
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Noppy View Post
    hence it was displaying 5000 records starting at 2500.
    to be precise, it was displaying 5000 rows starting at 2501

    the first parameter is the number of rows to skip over

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •