--DROP TABLE IF EXISTS "従業員表";
CREATE TABLE IF NOT EXISTS "従業員表" ("従業員ID", "苗字", "名前", "年齢");
INSERT INTO "従業員表" VALUES
(1001, '田中', '一郎', 31),
(1002, '山田', '花子', 28)
;
--DROP TABLE IF EXISTS "メニュー表";
CREATE TABLE IF NOT EXISTS "メニュー表" ("メニューID", "メニュー名", "料金");
INSERT INTO "メニュー表" VALUES
(101, '電気治療', 5000),
(102, '全身', 4500),
(103, '足つぼ', 1500),
(104, '頭皮マッサージ', 2000)
;
--DROP TABLE IF EXISTS "担当表";
CREATE TABLE IF NOT EXISTS "担当表" ("従業員ID", "メニューID");
INSERT INTO "担当表" VALUES
(1001, 101),
(1001, 102),
(1001, 103),
(1001, 104),
(1002, 102),
(1002, 104)
;
SELECT
"苗字"||"名前" AS "施術者",
group_concat("メニュー名") AS "メニュー"
FROM "従業員表" NATURAL INNER JOIN "担当表" NATURAL INNER JOIN "メニュー表"
GROUP BY "従業員ID";