Author Topic: help with limit in a sql query  (Read 365 times)

0 Members and 1 Guest are viewing this topic.

Offline turkmanTopic starter

  • Enthusiast
  • Posts: 151
    • View Profile
help with limit in a sql query
« on: March 03, 2010, 09:20:57 AM »
I'm wondering if its possible to get a record of all but the 100 most recent entries using the a lastpost datetime()

i.e SELECT * FROM table WHERE replytoo = '0' ORDER BY Lastpost desc LIMIT(100,1000)

so this query would put the most recently posted records on top then ignore the first 100 and extract 100 to 1000 for example

??

Can you use limit like this?

Offline Twister1004

  • Enthusiast
  • Posts: 189
  • Gender: Male
  • PHP 5.5 MySQL 5.5
    • View Profile
Re: help with limit in a sql query
« Reply #1 on: March 03, 2010, 08:48:10 PM »
I dont think you can use it like that. I believe you need to use mysql_select() or something, or use mysql_rows in a while loop and then echo those out.
The world of developing never ceases.

If the time for helping someone comes to this day, wouldn't you be glad to help someone that is trying to?

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: help with limit in a sql query
« Reply #2 on: March 04, 2010, 09:56:05 AM »
Without the parens, that's valid syntax... but it's not very efficient.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.