Query Second or Third Level Child

My data model has are more than two levels. How can I include in where clause 2 and third level child objects.

In your documentation about querying related objects, you have an example of related objects: phonebook, contact, and address. The example query is based on the contact object class. How would you write the same query using the phonebook class? Find all Phonebooks where “address.city = ‘Smallville’”

StringBuilder whereClause = new StringBuilder();whereClause.append( “PhoneBook[contacts]” );whereClause.append( “.objectId=’” ).append( savedPhoneBook.getObjectId() ).append( “’” );whereClause.append( " and " );whereClause.append( “address.city = ‘Smallville’” ); BackendlessDataQuery dataQuery = new BackendlessDataQuery();dataQuery.setWhereClause( whereClause.toString() );List<Contact> result;result = Backendless.Persistence.of( Contact.class ).find( dataQuery ).getCurrentPage();

Hi Barry,

if you want to find all phonebooks where contact address city is ‘Smallville’, the where clause should look next way:

contacts.address.city='Smallville'

I am getting an error using that syntax. From the console, I am getting “invalid where clause.”

Cool. It is now working