+ Start a Discussion
ScottGScottG 

Parenthesis requirements in SOQL??

Is it now, or has it ever been, possible to submit a SOQL statement similar to this:

SELECT firstname, lastname, email, id from CONTACT WHERE FIRSTNAME = 'scott' AND LASTNAME='last' OR LASTNAME='last2'

Using sforce Explorer, I get a MalformedQuery Exception and have to add parens to the statement:

SELECT firstname, lastname, email, id from CONTACT WHERE FIRSTNAME = 'first' AND (LASTNAME='last' OR LASTNAME='last2')

 

Is there no order of precedence for ANDs and ORs in SOQL? Or is precedence only determined by using parens?

Thanks

DevAngelDevAngel

Hi ScottG,

We do require explicit order preference by way of parens.