Created
July 26, 2011 22:34
-
-
Save timbroder/1108255 to your computer and use it in GitHub Desktop.
remove brand dupes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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