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
Aditya 8Aditya 8 

SOQL Query Doesn't work

SELECT Name, Payroll_Cd__c, Non_Payroll_Cd__c, Account_Status__c, Type, Non_Payroll_Eff_Dt__c, Non_Payroll_Exp_Dt__c  
FROM Account
WHERE   RecordType.Name = 'CORP_SALES' AND Account_Status__c = 'Active' AND (Type = 'Employer' OR Type ='Partner') AND Payroll_Cd__c  Like '%3253'

So here is the thing when i use " like" it works for all records and if i use the same query with "=" it  doesn't work for all records. But if i change the code to someother like Ex 3251 and put "=" it works i dont know whats wrong. Please if anyone faced the same issue your suggestions are much needed.

Thanks.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
That means there are no records with Payroll Cd 3253  which satisfy all conditions.
Aditya 8Aditya 8
But there are records in the Accounts Shalabh
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Can you run the same query in workbench to see if it returns records?
Aditya 8Aditya 8
I did and it doesn't return any
SalesFORCE_enFORCErSalesFORCE_enFORCEr
That means something in your record does not match as defined in the query.
Laraib_JafriLaraib_Jafri
Syntax wise i don't see anything wrong with your query. Make sure the criteria you're searching on is valid.
Aditya 8Aditya 8
So here are more details when i use Like the Query works absolutely fine but i dont want to use it because It is not effective. But when i use "=" it is not wokring for few records. For EX if the original code is 1212 and i run the query it doesn't work but if i change the code to some other value and run the query it works.