Reputation: 291
I am able to retrieve the latest entry in node-mysql with:
connection.query('SELECT * FROM NewsV2 ORDER BY IDCode DESC LIMIT 1',
function(err, rows, fields) {}
But, I would like to retrieve the latest say ten entries, how can I achieve this?
Upvotes: 0
Views: 24
Reputation: 4299
If you have a column for date, you would add that to the query
ORDER BY IDCode DESC Date DESC
and if you want 10, change the limit like so: LIMIT 10
.
If IDCode isn't the id col, and you happen to be adding new rows at a time, you can also add the sort ORDER BY ID DESC
but I'll guess your IDCode is your ID field.
Upvotes: 0