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
EldonEldon 

Error when we query opportunitylineitiems from products

1.Why are we getting error When we query like this in query editor?
SELECT Name, (SELECT Name FROM OpportunityLineItem)  FROM Product2

2.Is there any relationship between Product2 and OpportunityLineItem because i see relationship in schema builder but cannot see any relation field in opportunity line item to product2
Best Answer chosen by Eldon
swati_sehrawatswati_sehrawat
Product2 and OpportunityLineITem are connected using pricebookentry.

You can rework your query as:
Select (Select Id From OpportunityLineItems) From PricebookEntry