+ Start a Discussion
gazzer82gazzer82 

SOQL Query Assistance, multiple Where

I am obviously missing something obvious, but this query just doesn't work, and i can't work out why, can somebody assist?

 

SELECT Id,Name,Amount,R2_Job_Ref__c,R2_Shipping_Post_Code__c,Shipping_Postcode_2__c
FROM Opportunity
WHERE Shipping_Postcode_2__c != R2_Shipping_Post_Code__c AND R2_Shipping_Post_Code__c != null

 

Thanks!

 

Gareth

Rakesh BoddepalliRakesh Boddepalli

In your where clause you cannot compare to a field value in the object.

 

So in your case Shipping_Postcode_2__c != R2_Shipping_Post_Code__c wont work .

First retrieve the results and use if condition to filter out the results.

 

 

dphilldphill
Yes, Rakesh is right. You can't run queries like you would in normal SQL.
gazzer82gazzer82

Ah i see, that's rather annyoing and inefficient.

 

But thanks for the reply, will stop banging my head aginst it and add another if loop :)

 

Cheers

 

Gareth