lahmanlite/sql/appearancespost.sql

33 lines
747 B
MySQL
Raw Normal View History

pragma foreign_keys = 0;
2024-01-28 06:09:06 +00:00
begin;
attach database 'baseball-raw.db' as 'raw';
2024-01-31 06:09:39 +00:00
create temp table if not exists appearancespost (
2024-01-28 06:09:06 +00:00
"year" numeric,
"player" text,
"team" text
);
insert into appearancespost
select distinct yearID, playerID, teamID
from 'raw'.battingpost
union
select distinct yearID, playerID, teamID
from 'raw'.pitchingpost
union
select distinct yearID, playerID, teamID
from 'raw'.fieldingpost;
2024-01-31 06:09:39 +00:00
create table if not exists appearancespost (
"year" numeric,
"player" text,
"team" text,
primary key("year","player"),
foreign key("player") references "people"("ID"),
foreign key("year","team") references "teamseasons"("year","team")
);
insert into main.appearancespost select distinct * from temp."appearancespost";
2024-01-28 06:09:06 +00:00
commit;