Select all lines except the last four
I have a table (news), I am trying to select all rows except the last four. The table has a field news_date (date format) and news_id (autoincremet). The result should be desc.
MySQL version: 5.0
Table structure
news_id (tinyint)
news_title (text)
news_date (date)
I tried this
Select *
FROM news AS n
JOIN
( SELECT news_id
FROM news
ORDER BY news_id
LIMIT 1 OFFSET 4
) AS lim
ON n.news_id < lim.news_id ;
Can anyone help me with this query?
0
source to share
2 answers
The reason LIMIT
allows you to set the offset.
SELECT * FROM mytable ORDER BY news_date LIMIT 3,18446744073709551615;
The starting line offset is 0 (not 1). For more information read 'SELECT Syntax' in the MySQL manual .
+1
source to share