function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mshelmanmshelman 

SOQL logic anomalies?

I've created a custom object “test1__c” in SF and a corresponding table “test1” in Oracle. Each has a single field “Name” and I’ve populated each with the same list:

 

Fred

Rose

Eugene

Liz

Andy

Inez

Siddartha

Avi

Jaime

 

Now I want a query that returns the names that don’t contain either an “a” or an “i” (case-insensitive). I’m using Sforce Explorer to run the SF queries.

 

So in Oracle:

 

select name from test1 where not (lower(name) like '%a%')

and not (lower(name) like '%i%')

 

Results:

 

Fred

Rose

Eugene

 

Alternatively, in Oracle:

 

select name from test1 where not (lower(name) like '%a%'

or lower(name) like '%i%')

 

Results:

 

Fred

Rose

Eugene

 

However, in SOQL I seemingly get different results:

 

select name from test1__c  where (not(Name like '%a%'))

and (not(Name like '%i%'))

 

Results:

 

Fred

Rose

Eugene

Inez

Liz

Andy

 

Or with the equivalent logic:

 

select name from test1__c  where  not(Name like '%a%' or Name like '%i%')

 

Results:

 

Fred

Rose

Eugene

Inez

Liz

Andy

benjasikbenjasik
we'll look into it. Have you logged a case as well?
mshelmanmshelman

How do I log a case? I have Developer Edition.

Mike