I can get this query to run if I remove the Join, but once I add the join, I get the following error:
Run-Time error '3135': Syntax error in Join Operation
sourceDB = "C:\sourcedb.accdb"
SQL = "SELECT e1.lid " & _
"FROM (eventlog e1 IN '" & sourceDB & "'" & _
"LEFT JOIN eventlog e2 ON e2.lid = e1.lid)"
Any advice on what I might be doing wrong
Try changing your code to the following:
sourceDB = "C:\sourcedb.accdb"
SQL = "SELECT e1.lid " & _
"FROM [" & sourceDB & "].[eventlog] AS e1 " & _
"LEFT JOIN eventlog AS e2 ON e2.lid = e1.lid"
You have an obvious syntax error in your query: the join must be between two Tables, not the Table and Database name. Take a look at this canonical example (re: https://msdn.microsoft.com/en-us/library/office/ff198084.aspx ) and correct your query correspondingly:
SELECT CategoryName, ProductName FROM Categories LEFT JOIN Products
ON Categories.CategoryID = Products.CategoryID;
Hope this will help. Best regards,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.