Select brings different results

Asked

Viewed 71 times

4

I’m having a problem at a SELECT:

SELECT * FROM documento WHERE idAdministrador = '1' AND modulo = 'funcionario' OR modulo = 'atestado'

I need you, if module is working or attested, to do the correct search... However, it does not search for those who have idAdministrator = '1', the query base is the module only... Returns independent of idAdministrator being 1 or not.

How do I make a SELECT to search for the ID first, and if it’s working module or attested, list it correctly?

  • 2

    idAdministrador = '1' AND (modulo = 'funcionario' OR modulo = 'atestado') ?

  • Post as answer. It worked, thank you too!

1 answer

6


Group sql conditions with ():

SELECT * 
FROM 
    documento 

WHERE 
    idAdministrador = '1' 
    AND (modulo = 'funcionario' OR modulo = 'atestado')

Otherwise it was probably being interpreted as idAdminstrador=1 e modulo='funcionario or modulo='atestado'.

  • It worked perfectly. Thank you very much! :)

  • 1

    @Andrébaill quiet. In need we are there.

Browser other questions tagged

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