· 8 years ago · Jan 26, 2018, 01:56 AM
1drop table if exists ai_brands_entered;
2drop table if exists ai_brands_new;
3
4create table ai_brands_entered as
5select * from ai_brands
6where brands_id in (select brands_id from ai_jumboni_brands_assoc)
7or brands_id in (select brands_id from ai_megadrops_brands_assoc)
8or brands_id in (select brand_id from ai_used)
9;
10
11delete from ai_brands where name in (select name from ai_brands_entered);
12
13create table ai_brands_new as
14select * from ai_brands
15group by name
16;
17
18drop table ai_brands;
19
20create table ai_brands as (select * from ai_brands_new) UNION (select * from ai_brands_entered);
21
22ALTER TABLE ai_brands CHANGE COLUMN brands_id brands_id INT(11) NOT NULL AUTO_INCREMENT
23, ADD PRIMARY KEY (brands_id)
24, ADD UNIQUE INDEX name_UNIQUE (name ASC) ;
25
26drop table if exists ai_brands_entered;
27drop table if exists ai_brands_new;