Hi,
My experience is all SQL server, so please excuse my complete ignorance.
I have "adapted" a SQL Server query to delete duplicates from a table. I have had to use a temp table as I find that I cannot use a self join (I can't read from the same table I am trying to delete from).
Anyway, I am running the query, and it just sits there indefinately (I killed it after 15 minutes - it took less than a second in SQL server). I am expecting it to delete approximately 400 rows from a table containing approx 17,000.
Anyway, your opinions as to what could be causing this to just run and run, any code adjustments and definately books on MySQL admin and SQL programming would be appreciated.
My experience is all SQL server, so please excuse my complete ignorance.
I have "adapted" a SQL Server query to delete duplicates from a table. I have had to use a temp table as I find that I cannot use a self join (I can't read from the same table I am trying to delete from).
Anyway, I am running the query, and it just sits there indefinately (I killed it after 15 minutes - it took less than a second in SQL server). I am expecting it to delete approximately 400 rows from a table containing approx 17,000.
Anyway, your opinions as to what could be causing this to just run and run, any code adjustments and definately books on MySQL admin and SQL programming would be appreciated.
Code:
create temporary table tempActivity
select * from Activity;
update Activity a
set a.Deleted = 1, a.UpdatedOn = CURRENT_TIMESTAMP
where a.Id = a.Id
and a.CurrentVersion = 1
and a.Deleted = 0
and a.Id < (select max(ta.Id)
from tempActivity AS ta
where ifnull(ta.CustomerNumber,0) = ifnull(a.CustomerNumber,0) and ifnull(ta.CustomerTelephoneNumber,'') = ifnull(a.CustomerTelephoneNumber,'') and ta.OccuredOn = a.OccuredOn and ta.EditorId = a.EditorId and ta.CurrentVersion = 1 and ta.Deleted = 0);