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
WminWmin 

A driving SObject type has already been set, all other entity types in the FROM clause must be relationships to the initial object.

I get an error during deployment validation: 

A driving SObject type has already been set, all other entity types in the FROM clause must be relationships to the initial object.

The query that defines the scope for a batch job works fine in the Sandbox:

"Select id, Expiry_date_of_your_license_to_trade__c, Has_Live_Contract__c, Licence_Reminders_Sent__c, Proprietor_First_Name__c, Proprietor_Email_Address__c, Operator_Main_Contact_Email__c, Main_Contract_Email_Lookup__c, Main_Contact_Lookup__c from Bid_Information__c where Has_Live_Contract__c = True and (Licence_Reminders_Sent__c < 1 or Licence_Reminders_Sent__c = NULL) and Main_Contract_Email_Lookup__c != \'\' and (Expiry_date_of_your_license_to_trade__c <='+ String.valueOf(expdate) +' and Expiry_date_of_your_license_to_trade__c != NULL)"

Any help would be appreciated.
ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

Seems like you are trying to access the related Object's fields in the same query which might be causing the issue.

Can you please check this post which might help in resolving the error:

https://salesforce.stackexchange.com/questions/257078/is-there-any-use-for-defining-additional-entity-types-in-a-soql-from-clause

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri