+ Start a Discussion

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
Product2 and OpportunityLineITem are connected using pricebookentry.

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