begin;
attach database 'baseball-raw.db' as 'raw';
create table if not exists teamcodes (
	"ID"	text,
	"franchise"	text
);

insert into teamcodes
select distinct teamid, franchid from "raw"."teams";

update teamcodes
set ID = 'WS9'
where ID = 'WAS' and franchise = 'WAS';

update teamcodes
set ID = 'PHP'
where ID = 'PH4' and franchise = 'PHQ';
commit;
