0

SOQL

SELECT Name, AirRegulator__c, AmountReview__c, BatteryCapacity__c, 
       ChargingTime__c, Length__c, NumberUnits__c, Rating__c, TankSize__c, 
       (SELECT UnitPrice FROM PricebookEntries) 
FROM Product2 
WHERE Id IN (SELECT Product2Id FROM PricebookEntries WHERE UnitPrice = 1)
LIMIT 4

Error

sObject type 'PricebookEntries' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.

PricebookEntries is not custom object

1 Answer 1

1

Your sub-select is the problem.

(SELECT Product2Id FROM PricebookEntries WHERE UnitPrice = 1)

PricebookEntries is a relationship name, not an sObject name. The sObject name, which you must use in a top-level SOQL query (as opposed to the parent-child subquery you're also using) is PricebookEntry.

Note that this exposes a subtle difference between your parent-child subquery and your sub-select. Each Product2 row in your query results will include a PricebookEntries relationship that contains all PricebookEntries for that product.

However, you'll only get back Product2 records that have at least one PricebookEntry whose UnitPrice is 1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .