Skip to content

Instantly share code, notes, and snippets.

@timbroder
Created July 26, 2011 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbroder/1108255 to your computer and use it in GitHub Desktop.
Save timbroder/1108255 to your computer and use it in GitHub Desktop.
remove brand dupes
drop table if exists ai_brands_entered;
drop table if exists ai_brands_new;
create table ai_brands_entered as
select * from ai_brands
where brands_id in (select brands_id from ai_jumboni_brands_assoc)
or brands_id in (select brands_id from ai_megadrops_brands_assoc)
or brands_id in (select brand_id from ai_used)
;
delete from ai_brands where name in (select name from ai_brands_entered);
create table ai_brands_new as
select * from ai_brands
group by name
;
drop table ai_brands;
create table ai_brands as (select * from ai_brands_new) UNION (select * from ai_brands_entered);
ALTER TABLE ai_brands CHANGE COLUMN brands_id brands_id INT(11) NOT NULL AUTO_INCREMENT
, ADD PRIMARY KEY (brands_id)
, ADD UNIQUE INDEX name_UNIQUE (name ASC) ;
drop table if exists ai_brands_entered;
drop table if exists ai_brands_new;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment