Query error using 1 Where and 2 joins in search query

Asked

Viewed 24 times

-1

Hello, I’m running the following query in mysql:

select * from usuarios where login='gamboamurilo' or email='[email protected]' and senha='8b0a60f71e758c8b27e7688ee754cd85' 
inner join permissoes on usuarios.permissoes=permissoes.id 
inner join dados_perfil on usuarios.id=dados_perfil.id_usuario;

However, it is returning me a syntax error, however, even after reading the documentation, I could not find such error, where it is and how to fix?

  • 2

    WHERE has to be after the INNER JOIN

  • 2

    select * from usuarios Inner Join permissions on usuarios.permissoes=permissoes.id Inner Join dados_perfil on usuarios.id=dados_perfil.id_usuario Where login='gamboamurilo' or email='gamboamurilogmail.com' and password='8b0a60f71e758c8b27e7688ee754cd85';

1 answer

2


INNER JOIN must appear before the WHERE clauses.

I would mount this query with the following structure:

select *
  from usuarios 
 inner join permissoes on usuarios.permissoes=permissoes.id 
 inner join dados_perfil on usuarios.id=dados_perfil.id_usuario
 where (usuarios.login='gamboamurilo'
        or usuarios.email='[email protected]')
   and usuarios.senha='8b0a60f71e758c8b27e7688ee754cd85';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.