Jump to content

[SOLVED] Select all but the first 3 rows


Glenugie

Recommended Posts

I'm looking to write a query that will select all rows but the first 3, basically because I have the first 3 rows displayed on my main page, and the rest are archived.

 

I was hoping I wouldn't have to resort to something like this:

$QueryAnnounce = mysql_query("SELECT PostedBy, AnnouncementBody, Date FROM GameAnnouncement ORDER BY TimeStamp DESC LIMIT 3,9999999999999");

Is there a way to just set the second value to the exact number of rows? And if so, would someone mind clarifying what it was? :)

 

Thanks in advance,

 

~Glenugie~

Link to comment
Share on other sites

Hi

 

That is the recommended way to do it.

 

If you really want to avoid that syntax then maybe something like this would do it:-

 

$QueryAnnounce = mysql_query("SELECT a.PostedBy, b.AnnouncementBody, c.Date
FROM (SELECT PostedBy, AnnouncementBody, Date FROM GameAnnouncement ORDER BY TimeStamp) a
LEFT OUTER JOIN (SELECT PostedBy, AnnouncementBody, Date FROM GameAnnouncement ORDER BY TimeStamp DESC LIMIT 3) b
ON a.PostedBy = b.PostedBy AND a.AnnouncementBody = b.AnnouncementBody AND a.Date = b.Date
WHERE b.PostedBy IS NULL");

 

Basically get all records and get the first 3 records, join the results with an outer join and then only return those where the matching records (ie the ones in the first 3) are empty.

 

Personally I would just use your original solution.

 

All the best

 

Keith

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.