这是我收到的错误。
错误详情:
SQL查询的解析失败。请检查SQL语法。一些技巧: 在第58行第1列解析错误。遇到:ALL(这个“全部”是 一个紧接着闭括号。)
这是我的查询。
SELECT ALL "TR-ID" . "TR-ID" , "Site List Data" . "TR-ID",
"Issue number from Issue Log",
"Project Risks" .
"Suvey Docs/Photos Uploaded to WS Repo",
"IPACK" .
"Submit for MIROR code",
"Forecasts" .
"Equipment Ordered Planned",
"Calix Blocker"
FROM
(SELECT "TR-ID" FROM "Site List Data" UNION
SELECT "TR-ID" FROM "Project Risks" UNION
SELECT "TR-ID" FROM "IPACK" UNION
SELECT "TR-ID" FROM "Forecasts")
ALL "TR-ID" LEFT OUTER JOIN
"Site List Data" ON ALL IDS. "TR-ID" = "Site List Data" . "TR-ID" LEFT OUTER JOIN
"Project Risks" ON ALL IDS. "TR-ID" = "Project Risks" . "TR-ID"
LEFT OUTER JOIN
"IPACK" ON ALL IDS. "TR-ID" = "IPACK" . "TR-ID"
LEFT OUTER JOIN
"Forecasts" ON ALL IDS. "TR-ID" = "Forecasts" . "TR-ID"
答案 0 :(得分:0)
您只能在all
之后立即使用select
关键字,不得在每个联接表后重复此关键字。但是你根本不需要all关键字。
答案 1 :(得分:0)
All是mysql中的关键字。
我认为你只是想对你的子查询进行别名,因此空间就是问题所在。我建议用方括号中的空格包装名称(并删除引号),例如[所有TR-IDS]。
您还使用了两个不同的名称:ALL TR-ID和ALL IDS。试试这个:
SELECT [ALL TR-IDS].[TR-ID], [Site List Data].[TR-ID], [Issue number from Issue Log], [Project Risks].[Suvey Docs/Photos Uploaded to WS Repo], IPACK.[Submit for MIROR code], Forecasts.[Equipment Ordered Planned], [Calix Blocker] FROM
(SELECT [TR-ID] FROM [Site List Data] UNION SELECT [TR-ID] FROM [Project Risks] UNION SELECT [TR-ID] FROM IPACK UNION SELECT [TR-ID] FROM Forecasts) [ALL TR-IDS]
LEFT OUTER JOIN [Site List Data] ON [ALL TR-IDS].[TR-ID] = [Site List Data].[TR-ID]
LEFT OUTER JOIN [Project Risks] ON [ALL TR-IDS].[TR-ID] = [Project Risks].[TR-ID]
LEFT OUTER JOIN IPACK ON [ALL TR-IDS].[TR-ID] = IPACK.[TR-ID]
LEFT OUTER JOIN Forecasts ON [ALL TR-IDS].[TR-ID] = Forecasts.[TR-ID]
答案 2 :(得分:0)
"全选"是一个有效的命令,但"所有"是默认值并假定如果没有给出(即"选择所有"或"选择不同"都有效,使用"选择"本身与&#相同34;选择所有")
因为"所有"在SQL命令中使用,你应该避免它的名称。同样在MySQL中使用反引号而不是像这样的双引号:
SELECT
`ALL_TR_IDS`.`TR-ID`
, `Site List Data`.`TR-ID`
, `Issue number from Issue Log`
, `Project Risks`.`Suvey Docs/Photos Uploaded to WS Repo`
, IPACK.`Submit for MIROR code`
, Forecasts.`Equipment Ordered Planned`
, `Calix Blocker`
FROM (
SELECT
`TR-ID`
FROM `Site List Data`
UNION
SELECT
`TR-ID`
FROM `Project Risks`
UNION
SELECT
`TR-ID`
FROM IPACK
UNION
SELECT
`TR-ID`
FROM Forecasts
) `ALL_TR_IDS`
LEFT OUTER JOIN `Site List Data` ON `ALL_TR_IDS`.`TR-ID` = `Site List Data`.`TR-ID`
LEFT OUTER JOIN `Project Risks` ON `ALL_TR_IDS`.`TR-ID` = `Project Risks`.`TR-ID`
LEFT OUTER JOIN IPACK ON `ALL_TR_IDS`.`TR-ID` = IPACK.`TR-ID`
LEFT OUTER JOIN Forecasts ON `ALL_TR_IDS`.`TR-ID` = Forecasts.`TR-ID`
ps:如果您停止在名称中使用空格,它将使您的SQL生活更轻松。