1
votes

Why is this SOQL query returning MALFORMED_QUERY: unexpected token: on

Select id FROM account 
where id = '0012000000I7MkRAAV' or id = '0012000000I7MkRAAV' 
and id = '0012000000I7MkRAAV'

Changing "and" to "or" returns the result just fine:

Select id FROM account 
where id = '0012000000I7MkRAAV' or id = '0012000000I7MkRAAV' 
or id = '0012000000I7MkRAAV'

I am executing the query in Force explorer.

2

2 Answers

4
votes

You need to group your and/or's so that its not ambiguous, e.g.

Select id FROM account where id = '0012000000I7MkRAAV' or (id = '0012000000I7MkRAAV' and id = '0012000000I7MkRAAV')
0
votes

The problem is that one account record can't has two ids in the same time. One object record has just one Id. In this query you can use only OR statement