Sql. table, date and time organized

0

I have a sql table that will contain appointment, date and time. I keep all three based on ID. I have a question regarding date and time.

id = 0; data 28/08/2018 - 13:11h
id = 1; data 26/08/2018 - 17:10h
id = 2; data 25/08/2018 - 11:15h

I want to organize the table this way:

id = 0; data 25/08/2018 - 11:15h
id = 1; data 26/08/2018 - 17:10h
id = 2; data 28/08/2018 - 13:11h

Because when I schedule a time and a date, I might have a clue to set the next alarm based on id 0. I am having problems with this, because when I save a date and a time, I do not know which one call

    
asked by anonymous 25.08.2018 / 02:29

1 answer

0

I believe you need a SQL query as you described yourself with DESC in the "data" field:

SELECT * FROM nome_da_tabela ORDER BY data DESC

But from what I realized you want to give an update on the line to change the ID according to the date, is this? . If it is, I do not advise doing this directly in the database table, but programmatically with a loop adding a new column and identifying the order (0,1,2, etc ...), or even changing the rule of business to use the query sorted by date.

I hope it helps!

Embrace, Herbert.

    
26.08.2018 / 10:44