我试图修复这个请求几个小时没有成功,所以我希望你们能帮助我找出问题所在:
SELECT ((
SELECT DISTINCT *
FROM (
SELECT REPLACE(source_name, "+", "") AS name
FROM events
WHERE source_name!=""
UNION
SELECT REPLACE(target_name, "+", "") AS name
FROM events
WHERE target_name!=""
)
) AS player_name,
(
SELECT COUNT(*)
FROM events
WHERE source_name=player_name AND event_name="beforePlayerBan"
) as nbr_bans,
(
SELECT COUNT(*)
FROM events
WHERE source_name=player_name AND event_name="beforePlayerKick"
) as nbr_kicks,
(
SELECT COUNT(*)
FROM events
WHERE
(source_name=player_name OR target_name=player_name)
AND event_name="afterBattleStarted"
) as nbr_battles,
(
SELECT COUNT(*)
FROM events
WHERE source_name=player_name AND result=0
) as nbr_wins,
(
SELECT COUNT(*)
FROM events
WHERE target_name=player_name AND result=0
) as nbr_defeats,
(
SELECT COUNT(*)
FROM events
WHERE (source_name=player_name OR target_name=player_name) AND result=1
) as nbr_ties,
(
SELECT COUNT(*)
FROM events
WHERE (source_name=player_name OR target_name=player_name) AND result=2
) as nbr_forfeits
错误是 SQLSTATE[42000]:语法错误或访问冲突:1248 每个派生表都必须有自己的别名,这很奇怪,因为我确实给每个表都赋予了自己的别名