Home > Blockchain >  Access - Syntax error (missing operator) in query
Access - Syntax error (missing operator) in query

Time:01-29

I've the following tables:

permissions

enter image description here

user_permissions

enter image description here

users

enter image description here

When trying to run the following query:

SELECT * FROM users as u 
LEFT JOIN user_permissions AS up ON u.id = up.id_user 
LEFT JOIN permissions AS p ON up.id_permission = p.id

I'm getting the following error:

enter image description here

What I'm missing?

CodePudding user response:

Here is the correct query:

SELECT * FROM users INNER JOIN (permissions INNER JOIN user_permissions ON permissions.id = user_permissions.id_permission) ON users.id = user_permissions.id_user WHERE (((users.username)='admin'));

According to @June 7 comment:

Access SQL is picky about parentheses for JOIN clauses (they are missing in your SQL). Use the query DesignView to get correct structure then switch to SQLView. The table aliases are not necessary

  • Related