MySQL Count values in a column, Update and replace value which has a limit amount -
i have problem mysql update statement. have more 100.000 entries in table. approaches not successful. (see below)
first, want count number of values (thats easy):
select values1 ,count(values1) table group value1 having count(value1) <= 1000;
second, want replace values of column values1 appears <= 1000 times.
so tried these statement:
update table t set t.value1 = "limitamount" exists (select value1 (select * table) f group f.value1 having count(f.value1) <= 1000);
when tried sql statement, received:
error code 1205. lock wait timeout exceeded. try restarting transaction.
try this
update table t set t.value1 = "limitamount" exists (select value1 (select * table) f f.value1 = t.value1 group f.value1 having count(f.value1) <= 1000);
notice where f.value1 = t.value1
condition in subquery
Comments
Post a Comment