+ Start a Discussion
anup-prakashanup-prakash 

SOQL query help

Hi

 

I am displaying data in a pageblock table and it is retrieving data on basis of a soql query.. I have two different custom objects BillingJunction__c and Product__c I am trying to write a query like this..

 

Select (select name__c from product__c where id = :Product_ID__c),Product_ID__c,Product_Qty__c, Sold_Price__c from BillingJunction__c where Customer_ID__c = :custID AND Bill_ID__c = :billID ]

 

where BillingJuction also stores the productID and I want to retrive the name as it has the ID

Best Answer chosen by Admin (Salesforce Developers) 
anup-prakashanup-prakash

Its working now after using wraper class..

All Answers

AsitM9AsitM9
Select (select name__c from product__r),Product_ID__c,Product_Qty__c, Sold_Price__c from BillingJunction__c where Customer_ID__c = :custID AND Bill_ID__c = :billID ]

 

anup-prakashanup-prakash

there isn't any relationship between them...

sushant sussushant sus
you have to write two different query for two object
AsitM9AsitM9

SFDC doesn't support inner query for such object which aren't related.

 

So you can break your query into two query.

anup-prakashanup-prakash
but it acts as foreign key here.. and I want to display t in a single table.
bujjibujji

check the below query.Hope it will work.

Select (select name__c from products__c),Product_ID__c,Product_Qty__c, Sold_Price__c from BillingJunction__c where Customer_ID__c = :custID AND Bill_ID__c = :billID ]

Thanks,
Bujji

anup-prakashanup-prakash

Hey Bujji thanks for replying.. but that didn't work.. I think I have to use a wrapper class to resolve it..

anup-prakashanup-prakash

Its working now after using wraper class..

This was selected as the best answer