我想知道是否有人可以快速查看我正在尝试编写的SQL查询,它基本上需要三个表,链接它们并将值粘贴到我创建的名为tblSearchEngine01的表中。正如您可能理解的那样,我使用MS Access Query生成了代码(虽然有效),但出于某种原因,在SQL中编写它时,它不再起作用了。问题似乎在SELECT字符串上。
我想知道是否有人能够达到顶峰,看看是否存在一些我缺少的高级问题或逻辑因此导致我这个问题。我查看了列出的所有表格和字段,似乎没有问题。也许我的空间引起了一个问题?
谢谢, 甲
st_sql = "INSERT INTO tblSearchEngine01 ([ID Event], [ID Project], [ID_Project_Phase], [Owner],[Contact], [Event], [Type], [Participant], [Role_type], [Commitment], [Description], [Identification_status], [Overall_status], [Status], [tblMasterListOfEventsNotes], [tblMasterListOfEventsHistoryNotes], [Automatic user entry], [Automatic date of entry]," & _
"[Automatic_user_entry], [Automatic_date_of_entry], [Expected start date], [Actual start date], [Expected completion date], [Actual completion date], [Effective date], [Priority])"
"SELECT [tblMasterListOfEvents].[ID Event], [tblMasterListOfEvents].[ID Project], [tblMasterListOfEvents].[ID_Project_Phase], [tblMasterListOfEvents].[Owner], [tblMasterListOfEventsHistory].[Contact], [tblMasterListOfEvents].[Event], [tblMasterListOfEventsHistory].[Type], [tblProjManagementPhaseParticipants].[Participant]" & _
"[tblProjManagementPhaseParticipants].[Role_type], [tblMasterListOfEvents].[Commitment], [tblMasterListOfEventsHistory].[Description], [tblMasterListOfEvents].[Identification_status], [tblMasterListOfEvents].[Overall_status], [tblMasterListOfEventsHistory].[Status], [tblMasterListOfEvents].[Notes]" & _
"[tblMasterListOfEventsHistory].[Notes], [tblMasterListOfEvents].[Automatic user entry], [tblMasterListOfEvents].[Automatic date of entry], [tblMasterListOfEventsHistory].[Automatic_user_entry], [tblMasterListOfEventsHistory].[Automatic_date_of_entry], [tblMasterListOfEvents].[Expected start date], [tblMasterListOfEvents].[Actual start date]" & _
"[tblMasterListOfEvents].[Expected completion date], [tblMasterListOfEvents].[Actual completion date], [tblMasterListOfEventsHistory].[Effective date], [tblMasterListOfEvents].[Priority]" & _
"FROM tblMasterListOfEvents INNER JOIN tblProjManagementPhaseParticipants ON tblMasterListOfEvents.[ID Event] = tblProjManagementPhaseParticipants.ID_Event)" & _
"INNER JOIN tblMasterListOfEventsHistory ON tblMasterListOfEvents.[ID Event] = tblMasterListOfEventsHistory.ID_Event"
答案 0 :(得分:1)
至少,您似乎缺少逗号 - 例如在[参与者]和[实际开始日期]之后(还注意?)。我发现this site对于这类事情非常方便。
INSERT INTO tblsearchengine01
([id event],
[id project],
[id_project_phase],
[owner],
[contact],
[event],
[type],
[participant],
[role_type],
[commitment],
[description],
[identification_status],
[overall_status],
[status],
[tblmasterlistofeventsnotes],
[tblmasterlistofeventshistorynotes],
[automatic user entry],
[automatic date of entry],
[automatic_user_entry],
[automatic_date_of_entry],
[expected start date],
[actual start date],
[expected completion date],
[actual completion date],
[effective date],
[priority])
SELECT [tblmasterlistofevents].[id event],
[tblmasterlistofevents].[id project],
[tblmasterlistofevents].[id_project_phase],
[tblmasterlistofevents].[owner],
[tblmasterlistofeventshistory].[contact],
[tblmasterlistofevents].[event],
[tblmasterlistofeventshistory].[type],
[tblprojmanagementphaseparticipants].[participant],
[tblprojmanagementphaseparticipants].[role_type],
[tblmasterlistofevents].[commitment],
[tblmasterlistofeventshistory].[description],
[tblmasterlistofevents].[identification_status],
[tblmasterlistofevents].[overall_status],
[tblmasterlistofeventshistory].[status],
[tblmasterlistofevents].[notes],
[tblmasterlistofeventshistory].[notes],
[tblmasterlistofevents].[automatic user entry],
[tblmasterlistofevents].[automatic date of entry],
[tblmasterlistofeventshistory].[automatic_user_entry],
[tblmasterlistofeventshistory].[automatic_date_of_entry],
[tblmasterlistofevents].[expected start date],
[tblmasterlistofevents].[actual start date],
[tblmasterlistofevents].[expected completion date],
[tblmasterlistofevents].[actual completion date],
[tblmasterlistofeventshistory].[effective date],
[tblmasterlistofevents].[priority]
FROM tblmasterlistofevents
INNER JOIN tblprojmanagementphaseparticipants
ON tblmasterlistofevents.[id event] =
tblprojmanagementphaseparticipants.id_event
INNER JOIN tblmasterlistofeventshistory
ON tblmasterlistofevents.[id event] =
tblmasterlistofeventshistory.id_event