ms access / sql server syntax (i guess)
this query:
SELECT sentmails.[VersandDatum],
sentmails.[DatumMailGeplant],
mailintervals.[Interval],
definitions.[Subject],
users.[Name],
sentmails.[MailArt],
Objekte.[Name],
sentmails.[Erledigt],
sentmails.[ID]
FROM Objekte
RIGHT JOIN (users RIGHT JOIN (definitions RIGHT JOIN (mai开发者_如何学运维lintervals RIGHT JOIN (sentmails) ON mailintervals.ID=sentmails.Intervall) ON definitions.ID=sentmails.Noti_ID) ON users.UID=sentmails.Funktion) ON Objekte.OId=sentmails.Objekt_ID
...works fine in ms access qbe, but in sql server it returns a "incorrect syntax near ')'" error. I'm really wondering why:
- the joins need to be in brackets?
- no more outer joins in sql server?
- somewhere more brackets needed?
MS Access has a slightly different JOIN syntax. Use this instead:
SELECT
sentmails.[VersandDatum],
sentmails.[DatumMailGeplant],
mailintervals.[Interval],
definitions.[Subject],
users.[Name],
sentmails.[MailArt],
Objekte.[Name],
sentmails.[Erledigt],
sentmails.[ID]
FROM Objekte
RIGHT JOIN sentmails ON Objekte.OId=sentmails.Objekt_ID
RIGHT JOIN definitions definitions.ID=sentmails.Noti_ID
RIGHT JOIN mailintervals ON mailintervals.ID=sentmails.Intervall
RIGHT JOIN users ON users.UID=sentmails.Funktion
Your JOIN
syntax is incorrect. You should be joining each table individually, without nested parentheses. You probably want something like:
SELECT sentmails.[VersandDatum]
, sentmails.[DatumMailGeplant]
, mailintervals.[Interval]
, definitions.[Subject]
, users.[Name]
, sentmails.[MailArt]
, Objekte.[Name]
, sentmails.[Erledigt]
, sentmails.[ID]
FROM Objekte
RIGHT JOIN sentmails ON Objekte.OId = sentmails.Objekt_ID
RIGHT JOIN users ON users.UID = sentmails.Funktion
RIGHT JOIN definitions ON definitions.ID = sentmails.Noti_ID
RIGHT JOIN mailintervals ON mailintervals.ID = sentmails.Intervall
Here's a starting point in MSDN.
精彩评论