#1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 'FROM Totaldata, eventvenue, band 附近使用的正确语法 WHERE Totaldata.band_name = eventvenue.headlin' 在第 3 行
INSERT INTO eventbandrevenue
SELECT DISTINCT eventvenue.eventvenue_id,
totaldata.band_name,
(0.60*(SELECT DISTINCT eventvenue.ticket_revenue
FROM eventvenue, band
WHERE eventvenue.headliner = band.band_name),
(0.60*(SELECT DISTINCT eventvenue.merchanndise_sales
FROM eventvenue, band
WHERE eventvenue.headliner = band.band_name)),
((0.60* (SELECT DISTINCT eventvenue.ticket_revenue
FROM eventvenue, band
WHERE eventvenue.headliner = band.band_name)
+
0.60*(SELECT DISTINCT eventvenue.merchanndise_sales
FROM eventvenue, band
WHERE eventvenue.headliner = band.band_name)))
FROM totaldata, eventvenue, band
WHERE totaldata.band_name = eventvenue.headliner
merchanndise_sales
可能是一个错字,可能应该是 merchandise_sales
下面删除了不必要的子查询并使用显式连接。
INSERT INTO eventbandrevenue
SELECT DISTINCT
ev.eventvenue_id,
td.band_name,
(0.60 * ev.ticket_revenue) as ticket_revenue_share,
(0.60 * ev.merchandise_sales) as merchandise_revenue_share,
(0.60 * (ev.ticket_revenue + ev.merchandise_sales)) as total_revenue_share
FROM totaldata td
JOIN eventvenue ev ON td.band_name = ev.headliner
JOIN band b ON ev.headliner = b.band_name