2
I used the following SELECT to find the repeated values:
SELECT nome, Count(nome) FROM projeto
GROUP BY nome
HAVING Count(nome)>1
Now I need to delete everything that is repeated and leave only the first that was inserted. I am trying to do it this way:
DELETE FROM projeto
WHERE nome IN
(SELECT nome FROM projeto
GROUP BY nome
HAVING Count(nome)>1)
AND NOT id_projeto IN
(SELECT Min(id_projeto) FROM projeto
GROUP BY nome
HAVING Count(nome)>1)
However, I am getting the following error: #1093 - You can’t specify target table 'project' for update in FROM clause
Any idea what might be wrong?
#tmp would be a variable or a temporary table?
– Sabrina T.
Temporary table.
– Sérgio Sereno
I couldn’t solve it, Sergio. If I could detail a little more maybe it would be a little more clear to me.
– Sabrina T.
Missing change * by Name, which is counted.
– Sérgio Sereno
I was able to solve along with this question also: https://stackoverflow.com/questions/18288245/delete-duplicate-rows-in-mysql Thanks, Sergio!
– Sabrina T.