0
I want to delete from the table users with the same name, but only those that the difference of the database date and the current date (at the time of select) are for example, less than 5 minutes.
The structure of my database is :
Login | Nome | Hora
0 joao 2015-05-30 12:05:06
1 joao 2015-05-30 12:13:06
2 joao 2015-05-30 12:07:06
As the subtraction of the dates between Login 0 and Login 2 of 2 minutes, it would delete the most recent one, which is login 2.
I am using the following Query to delete equal names :
DELETE a FROM tabela AS a, tabela AS b WHERE a.nome=b.nome AND a.login < b.login
I am using MYSQL ,thank you !
If that’s your chart, what would be the result you want to get?
– bruno
so,I want it to delete the same names, only if the current date - the date in the database is less than 5 minutes. if they have 5 equal names, but one of them has 2 minutes to the other, delete it. the difference between dates has to be greater than 5 minutes
– saidmrn
What about Login1? Why isn’t it deleted? It’s newer than Login2?
– bruno