+ 1

Database

I'm new to coding and trying to build an Android app, where you can track your cigarettes you smoked... So far I got a database where I can add values and display them again... Now I want to compare the last time I smoked with now... I'm stuck in getting the last entry of the database back! Maybe someone can help me out?

10th May 2018, 7:52 AM
Enrico Riedel
Enrico Riedel - avatar
2 odpowiedzi
+ 1
SELECT * FROM `smoked` ORDER BY `date` DESC LIMIT 1 I'm making a lot of assumptions here about your tables. If you don't have a date field order it descending by the primary key which should be auto incrementing.
10th May 2018, 10:26 AM
Adam
Adam - avatar
+ 1
Thank you Adam... You helped a lot....
10th May 2018, 11:17 AM
Enrico Riedel
Enrico Riedel - avatar