Commit df0210d9 authored by Daniel Kim's avatar Daniel Kim
Browse files

delete a file

parent d0214610
-- country
drop table if exists temp;
CREATE TABLE temp (val varchar(128));
drop table if exists temp2;
create table temp2 (val varchar(128));
drop procedure if exists parseCountry;
DELIMITER ;;
create procedure parseCountry()
begin
declare n int default 0;
declare i int default 0;
select count(distinct `country`) from `imdbmovies` into n;
insert into temp2 (val) select distinct `country` from `imdbmovies`;
set i = 0;
while i < n do
SET @S1 = CONCAT("INSERT INTO temp (val) VALUES ('",
REPLACE(REPLACE((SELECT * FROM temp2 limit i, 1),
"'",
""), ",", "'),('"),
"');");
PREPARE stmt1 FROM @s1;
EXECUTE stmt1;
set i = i + 1;
end while;
end;
;;
DELIMITER ;
call parseCountry();
drop table if exists Country;
create table Country (name varchar(128));
insert into Country(name) select distinct ltrim(val) from temp;
select * from Country;
-- language
drop table if exists temp;
CREATE TABLE temp (val varchar(128));
drop table if exists temp2;
create table temp2 (val varchar(128));
drop procedure if exists parseLanguage;
DELIMITER ;;
create procedure parseLanguage()
begin
declare n int default 0;
declare i int default 0;
select count(distinct `language`) from `imdbmovies` into n;
insert into temp2 (val) select distinct `language` from `imdbmovies`;
set i = 0;
while i < n do
SET @S1 = CONCAT("INSERT INTO temp (val) VALUES ('",
REPLACE(REPLACE((SELECT * FROM temp2 limit i, 1),
"'",
""), ",", "'),('"),
"');");
PREPARE stmt1 FROM @s1;
EXECUTE stmt1;
set i = i + 1;
end while;
end;
;;
DELIMITER ;
call parseLanguage();
drop table if exists Language;
create table Language (name varchar(128));
insert into Language(name) select distinct ltrim(val) from temp;
select * from Language;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment