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
neil12neil12 

NOT EQUAL operator IN SOQL for picklist values

How to use not qual to operator in SOQL

 

In sql, fieldname !='%xyz%'

 

how about soql?

 

here am trying to check for the picklist values.

 

Thanks in advance

Suresh RaghuramSuresh Raghuram

In soql you can use as follows

 

Select Id, Name from opportunity where StageName != 'closed' limit 10

 

Select Id, Name from opportunity where StageName <> 'closed' limit 10

 

Select Id, Name, StageName from opportunity where StageName <> '%lose%' limit 10

 

Select Id, Name, StageName from opportunity where StageName != '%lose%' limit 10

 

 

If this answers your question make this as a solution and give KUDOS plz.

sandeep@Salesforcesandeep@Salesforce

for equal you need to check as below 

 

[select id from Account where Name = : NameVariable ]

 

but in case of value 

[select id from Account where Name = 'Sandeep' ]

 

ans in case of Inequality : 

[select id from Account where Name != : NameVariable ]

 

but in case of value 

[select id from Account where Name != 'Sandeep' ]

 

AsiereikiAsiereiki

Hi,

 

I see you are trying to make a LIKE or NOT LIKE.

 

LIKE exists in SOQL but NOT LIKE doesn't exists, so you need to use this:

 

select Name from Account Where NOT fieldname  like '%xyz%'