我試圖將Access INSERT查詢轉換爲MySQL Pass Through Query,但我不太熟悉MySQL。我知道我的語法是關閉的,但我不確切知道問題是什麼。試圖將訪問插入查詢轉換爲MySQL查詢
Access版本:
INSERT INTO [tblHistoryThruToday RETAIN-STU-ADVISOR] ([STUDENT ID], [ADVISOR ID], [COURSE TERM], [BLANK ADV TERM], [BLANK ADV TYPE], [BLANK DEPARTMENT], [BLANK PRIMARY ID], SOURCEFILE, [TIMESTAMP])
SELECT [tblHistory - RETAIN-STU-ADVISOR].[STUDENT ID], [tblHistory - RETAIN-STU-ADVISOR].[ADVISOR ID], [tblHistory - RETAIN-STU-ADVISOR].[COURSE TERM], [tblHistory - RETAIN-STU-ADVISOR].[BLANK ADV TERM], [tblHistory - RETAIN-STU-ADVISOR].[BLANK ADV TYPE], [tblHistory - RETAIN-STU-ADVISOR].[BLANK DEPARTMENT], [tblHistory - RETAIN-STU-ADVISOR].[BLANK PRIMARY ID], [tblHistory - RETAIN-STU-ADVISOR].SOURCEFILE, [tblHistory - RETAIN-STU-ADVISOR].TIMESTAMP
FROM [tblHistory - RETAIN-STU-ADVISOR];
我嘗試在MySQL的(我有我的表名兩邊的'標記,但你可能無法看到他們在預覽)
INSERT INTO `tblHistoryThruToday RETAIN-STU-ADVISOR` (‘STUDENT ID’, ‘ADVISOR ID’,’COURSE TERM’, ‘BLANK ADV TERM’,’BLANK ADV TYPE’, ‘BLANK DEPARTMENT’, ‘BLANK PRIMARY ID’, ‘SOURCEFILE’, ‘TIMESTAMP’)
SELECT `tblHistory - RETAIN-STU-ADVISOR`.‘STUDENT ID’, `tblHistory - RETAIN-STU-ADVISOR`.‘ADVISOR ID’, `tblHistory - RETAIN-STU-ADVISOR`.‘COURSE TERM’, `tblHistory - RETAIN-STU-ADVISOR`.‘BLANK ADV TERM’, `tblHistory - RETAIN-STU-ADVISOR`.‘BLANK ADV TYPE’, `tblHistory - RETAIN-STU-ADVISOR`.‘BLANK DEPARTMENT’, `tblHistory - RETAIN-STU-ADVISOR`.’BLANK PRIMARY ID’, `tblHistory - RETAIN-STU-ADVISOR`.‘SOURCEFILE’, `tblHistory - RETAIN-STU-ADVISOR`.‘TIMESTAMP’
FROM `tblHistory - RETAIN-STU-ADVISOR`;
這些表名,用空格和破折號和不同類型的情況下,是開發商憤怒誘導。你不能拿出更簡潔,更容易閱讀的東西嗎? – tadman
讓我們試試這個更通用的版本,但解決了同樣的問題。 「表A」和「表B」都是表格,不幸的是,名稱中有空格。 INSERT INTO'表A'(「學生ID」,「顧ID」) SELECT'表B'.'STUDENT ID」,'表B'.'ADVISOR ID」 FROM'表B'; – user2839132