SQL Parentheses use in an OR clause -
was wondering whether know why use parentheses in sql: so, format goes follows:
name,location , department of service of employees name starts or b. (a rough translation french).
i answered following way:
select service.nom_serv, localite.ville, localite.departemen service, localite, employe service.code_loc=localite.code_loc , employe.service=service.code_serv , ((employe.nom 'a%') or (employe.nom 'b%'))
basically, last , concerned where, couldn't without parenthesis in order have sql select me employees name starting either or b? difference positioning parenthesis in way make? , ahy there double use of parentheses? or prioritize or in last clause, since , preceding it?
take @ operator precedence in sql server (you've not specified that, i'd imagine it's same rdbms). means ands (without parenthesis) evaluated before ors.
so in specific case, without parenthesis, conditions are:
employe.service=service.code_serv , employe.nom 'a%'
or
employe.nom 'b%'
Comments
Post a Comment