+ Start a Discussion
eswar R 1eswar R 1 

In one of the object there are two fields called Field1 and Filed2 exist and we have 100,000 records, out of 70,000 record values are equal in field1 and field2. Now Display those 70,000 records on visualforce page.

SOQL cannot be used for Field to Field comparison directly.

Easy way is to create a formula field to do the comparison and set a boolean value.

You can use the formula in your SOQL query.

Your SOQL query will look like this.
SELECT Id, Name, field1__c, field2__c FROM Object1__c WHERE Field_Compare__c = true
Field_Compare__c will be your formula field which returns true (a boolean output) if field1 = field 2, it will return false if field1 <> field2.

Hope this helps.
Vinuthh SVinuthh S
Hi Eswar 

SELECT Id, Name, field1__c, field2__c FROM Object1__c WHERE field1__c = field2__c;

Use this query and display it in VF Page.

Vinuthh S