I get the
"Syntax error (missing operator) in query expression..."
When running this query from one Excel spreadsheet to another using Provider=Microsoft.ACE.OLEDB.12.0
select Distinct [set$].F1 as SETID, [set$].F7 as SetVolume, [tray$].F8 as fracwidth
from [set$]
Left join [traysinset$] as TS1 on [set$].F1=TS1.F2
Left join [traysinset$] as TS2 on TS1.F3=TS2.F2
Left join [tray$] on [tray$].F1=TS1.F3 or [tray$].F1=TS2.F3
where [set$].F1 <>'' and [set$].F1 is not Null and [tray$].F8 <>'' and [tray$].F8 is not Null and [tray$].F8 <>'NULL'
ORDER BY [set$].F1 ASC, [tray$].F8 ASC
I know the issue is my joins and have tried various bracketing and nesting but can't seem to crack it. I have successfully run the query in SQL server management studio as the below so I'm really stumped as to why it doesn't work in Excel.
select Distinct [set].id as SETID, [set].volume as SetVolume, [tray].fracwidth as fracwidth
from [myserver].[dbo].[set]
Left join [myserver].[dbo].[traysinset] as TS1 on [set].id=TS1.setid
Left join [myserver].[dbo].[traysinset] as TS2 on TS1.trayid=TS2.setid
Left join [myserver].[dbo].[tray] on [tray].id=TS1.trayid or [tray].id=TS2.trayid
where [set].id <>'' and [set].id is not Null and [tray].fracwidth <>'' and [tray].fracwidth is not Null and [tray].fracwidth <>'NULL'
ORDER BY [set].id ASC, [tray].fracwidth ASC
All help much appreciated.