Reputation: 291
I use this query to get the newest 1 entry:
SELECT * FROM Data ORDER BY ID DESC LIMIT 1
I am using node-mysql
in nodeJS
, I would like to use the
rows[0].Data
So I can get the 4 newest entries in separate variables, how can I achieve this?
I am aware that I can up the DESC LIMIT to 4, to limit the results, but am still failing trying to get more than 1 result.
Upvotes: 2
Views: 30
Reputation: 133400
for the 4 recent the sql is
SELECT * FROM Data ORDER BY ID DESC LIMIT 4
for obtain the data should be
rows[0].Data
rows[1].Data
rows[2].Data
rows[3].Data
Upvotes: 2