Files
src-1.2/game/server/database/queries/objvar_name_make_distinct.sql
T
2014-01-17 07:03:16 -07:00

21 lines
580 B
SQL

create table temp_objvar_renum
as select id, right_id
from object_variable_names ovn, (select min(id) right_id, name
from object_variable_names
group by name
having count(*) > 1) subq
where ovn.name = subq.name
and id <> right_id;
update object_variables
set name_id = (select right_id from temp_objvar_renum where object_variables.name_id = temp_objvar_renum.id)
where name_id in (select id from temp_objvar_renum);
delete object_variable_names
where id in (select id from temp_objvar_renum);
drop table temp_objvar_renum;
delete object_variable_names
where name is null;