1
Among the fields in the table there is the name field, the dt_add field which is the date that the record was inserted and dt_update which is the date of the last update of the record.
I would like to know how to return and delete repeated records, for example if there are 100 records with equal names, delete those with last update date less than 01/11/2017
Explaining better:
In a system a problem was found that there were as a consequence insertions let’s say of more than 16 thousand repetitions for about 100 records with the same name and value in a given table.
It seems surreal, but more than 16 thousand duplicated records for each value and the error occurred with about 100 values. The error was perceived after analysis due to high resource consumption of the server, and it was observed that the error has existed since 2014 due to dates of insertions and updates of the records.
What will be done is delete all those that are repeated with date less than 01/11/2017 in order to mitigate the consumption of resources and will be made the system correction.
I don’t know if I could be clear enough for the context.
In short I need an SQL select
to return all the repeated records and a delete
in order to delete repeated records with date less than 01/11/2017.
About primary key
It has primary key yes, but it is a table of settings where there should be unique records (if not this problem) and the system is based on the reference of the configuration name and value.
Example:
nome : habilitar-alertas
valor: true
nome : bloquear-clientes-pendentes
valor: false
explain better what you need please, and put the code you’re trying to do
– Rovann Linhalis
I need an SQL select to return all repeated records and a delete in order to delete repeated records with a date less than 01/11/2017.
– Anderson Brunel Modolon
Do you have a primary key for this table ? Or just the 3 columns cited?
– Rovann Linhalis
In the database, the dates are like,
date
?– I_like_trains
Are the kind
datetime
– Anderson Brunel Modolon