I have a SQLITE DB with the name of each image file in a column
How can I retrieve and display the last 3 image files that were inserted?
Thank you for your help.
have a field in each row that records the insertion date and time, or some increasing order and sort by that, then take the last 3
Otherwise, you cant reliably do it… a SQL select doesnt promise to return things in any particular order unless you apply a SORT
if each row gets an increasing number, then you can take the highest number, and select rows
where rownumber >= maxnumber -2
rownumber is ‘select max(rownumber) from table’ … you could have that in the SQL, using something like
where rownumber >= (select max(rownumber) from table) -2
1 Like
Do you have an index that auto-increment? In other words can you do a
SELECT image_name FROM image_table ORDER BY id DESC LIMIT 3
2 Likes
Thanks, I’ll give it a try