You need to sign in to do that
Don't have an account?

SOQL Query.....
I can't find what I am doing wrong here though I have done it 10000 time before, something is not returning correctly.
I have an Custom_Object__c with fields Status__c and Type__c
I have 10 records Status__c = 'Open' and Type__c = 'New'
I have 20 records Status__c = 'Closed' and Type__c = 'New'
I run this query and for some reason am running into this problem
for(Custom_Object__c c: [Select Status__c from Custom_Object__c where (Status__c = 'Open' OR Status__c = 'Closed') and Type__c = 'New']){}
This query 10 rows are returned
for(Custom_Object__c c: [Select Status__c from Custom_Object__c where (Status__c = 'Closed' OR Status__c = 'Open') and Type__c = 'New']){}
This query 20 rows are returned.....any ideas whats wrong with this logical OR statement that is not returning all 30 rows?
Nothing looks wrong in your query but just try this for now
let me know with the results.
All Answers
I tried same thing on my org :
And it is working absolutely fine, wondering why not working at your end. Hope there is not any data issues on your org.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Nothing looks wrong in your query but just try this for now
let me know with the results.
Lists seem to return all results, but doesn't explain why the OR statements are not returning the expected results. I probably have hundreds of lines of code where I have used OR statements in the past and retrieved the expected result - I will go back and check if those no longer work as well.
I also have used OR statement with success I will need to check also. But I would request you to mark it as solution so that in case some one other also gets into same issue he has a solution to move ahead. So please mark it as Accepted solution so that otehrs can also benifitted from it.
This is strange, will this solution work for the date fields as well???
The problem is why OR is not working. As it is working at our end then why not yours?
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Very sorry for this, the query I was running was an actually much more complex version of what I stated. I did alot of data manipulation to create a complex binding query to return a result and realized there was an extra space before one of my text literal values so it was not returning results of that value. Thanks to those who looked into it - sorry for wasting your time.
No issues we all do these things. Thanks for updating on it.
That's what I was wondering. There is nothing extra done using a set or a list instead of OR then what exactly should be the problem. And have already notified you that it must be data issue.
Anyways, thanks for sharing this. I really appreciate it.
Thanks
Ankit Arora
Blog | Facebook | Blog Page