I have three custom objects: Book, Loan, and Reader. Loan is a junction object with lookup relationship with both Book and Reader. The diagram below shows their relationship:
I want to write a SOQL query to retrieve the Loan name and Active status from Loan object, Book title and subject from Book object, and Reader name and specialization subject from Reader object.
I wrote the following query but it showing an error:
SELECT Active__c, Name, (SELECT Name, Subject__c FROM Book__r), (SELECT Name, Specialization_Subject__c FROM Reader__r) FROM Loan__c
I get the following error message:
Didn't understand relationship 'Book__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.