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
Bhoomi PatilBhoomi Patil 

how to query conditional statements for two different custom fields from two different custom objects

I m trying to query two fields from two different custom objects with 'where'  condition.
Scenario:ObjA--> Customer name , customer Code
ObjB--> Invoice Number 
Conditon: want to display all the customer names and  code who has Invoice number .
Note:ObjB field exist in the quick action of ObjA

So Far i've written the query below
select id,customerName and Customer_code ,(select id,Invoice_number from  ObjBs__r) from opportunity --> here all the customername and customer codes are getting displayed . But am looking for only those customer names whose invocie number are attached to this it. 

Thanks in advance 
 

v varaprasadv varaprasad
Hi Patil,

ObjA and ObjB have any relationships or not.If yes please let me know which one is parent and child.

Sample query to fetch account having contacts

select id,name from account where id in (select accountid from contact);

Hope it helps you.

Thanks
Varaprasad

 
Bhoomi PatilBhoomi Patil
Master detail relationship exist
I'm quering as
Select Customer_name , customer_Code from ObjA where customer_code in ( select customer_code, inovice number from ObjBs__r)

Its throwing  error as unkown parsing