Select brings different results

4

I'm having a problem with a SELECT:

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

I need to know if the module is an OR certificate, which does the correct search ... However, it does not search for the ones that have idAdministrator = '1', the query base is the module only ... Returns independent of theAdministrator be 1 or not.

How do I make a SELECT that searches the ID first, and if it is an official or certified module, list it correctly?

    
asked by anonymous 24.09.2015 / 14:06

1 answer

6

Group conditions in sql 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' .

    
24.09.2015 / 14:20