SELECT * FROM nieuws ORDER BY id DESC LIMIT 2
- selects last 2 items
SELECT * FROM nieuws ORDER BY id DESC LIMIT 1, 1
- selects only second item
SELECT * FROM nieuws ORDER BY id DESC LIMIT 2
- selects last 2 items
SELECT * FROM nieuws ORDER BY id DESC LIMIT 1, 1
- selects only second item
LIMIT
can take two arguments:
SELECT ... LIMIT 1, 1
If you want to display the latest two items, then you can get both at the same time by limiting to 2 instead of 1. This means it's only one database hit to get the information you need.
SELECT * FROM nieuws ORDER BY id DESC LIMIT 2
Or if you only want the second row, you can give an offset to the LIMIT, to tell it which row to start from, (Although if you get the first row in one query, then get the second in another, you're doing two database hits to get the data you want, which can affect performance).
SELECT * FROM nieuws ORDER BY id DESC LIMIT 1, 1
You can find out more information on how to use the LIMIT clause in the MySQL documentation.
SELECT * FROM nieuws ORDER BY id DESC LIMIT 1, 1
That should give you second last record.