I apologize in advance... I know this has been covered before, but I've spent the last hour or so hunting through the forums looking for the solution and I can't figure out the right way to phrase my search to get what I'm looking for.
I have a query where I'm selecting an entire table and ordering the results in DESC order by date, then using LIMIT on that so that only 5 results show. However, the problem I have is that I want to exclude the latest two entries in the table. My code is :
$sql = "SELECT * FROM news WHERE news_type = '1' ORDER BY news_date DESC LIMIT 5";
The "news_date" field is a UNIX Timestamp.
This works fine... it collects all 5 of the latest database entries for the "news" table that have the "news_type" as 1, and orders them by the most recent date. However, what I need to do is have the two most recent entries excluded from this, so essentially the sql returns only results beginning with the 3rd most recent database entry (with news_type still as 1 - there are multiple news types).
So, in case that doesn't make too much sense, here's an example of my database :
DATE | TITLE | BODY | Type |
---------------------------------------------------
20080605 | Some News | Lots of text | 0 |
---------------------------------------------------
20080604 | More News | Lots of text | 1 |
---------------------------------------------------
20080603 | Early News | Lots of text | 0 |
---------------------------------------------------
20080602 | Fixed News | Lots of text | 1 |
---------------------------------------------------
20080601 | Bad News | Lots of text | 1 |
---------------------------------------------------
20080531 | Good News | Lots of text | 0 |
---------------------------------------------------
20080530 | Tues News | Lots of text | 1 |
---------------------------------------------------
20080529 | Page News | Lots of text | 1 |
---------------------------------------------------
20080528 | Site News | Lots of text | 1 |
---------------------------------------------------
20080527 | Latest News | Lots of text | 1 |
---------------------------------------------------
The results I'm looking for with my query would be :
[code]
20080601 | Bad News | Lots of text | 1 |
20080530 | Tues News | Lots of text | 1 |
20080529 | Page News | Lots of text | 1 |
20080528 | Site News | Lots of text | 1 |
20080527 | Latest News | Lots of text | 1 |
[/code]
Thanks a lot in advance... I know the solution is very simple, I just can't seem to find it anywhere.