Forum Moderators: coopster

Message Too Old, No Replies

Omitting the first 3 results from mysql query

         

ShoT

10:28 pm on Jan 17, 2008 (gmt 0)

10+ Year Member



Hey guys, I want to show recently added database items, so my query would look like:


mysql_query("SELECT * FROM gallery_category ORDER BY category_id DESC LIMIT 3",$connect);

So thats going to give me the 3 most recently added items, how about if I wanted it to display all of the items, also in a descending order, but without the first 3 results, I dont think its nothing too complicated but I still have no idea how to go about it. thx

eelixduppy

11:21 pm on Jan 17, 2008 (gmt 0)



You'd have you use an offset in your LIMIT so it would be something like this:

$query = "SELECT * FROM gallery_category ORDER BY category_id DESC LIMIT 3, 9999999999999999";

The only problem is that you have to use a high number as where to stop, so for instance what I have above. I do not think there is another way to do this unless you filter out the first 3 results using php itself. Try this and see how it works.

ShoT

11:53 pm on Jan 17, 2008 (gmt 0)

10+ Year Member



Works fine man, thanks alot.