Table Retailers has one to many relation with table Beacons and table Beacons has one to many relation with table BeaconLocalNotify. I am using following query to retrieve the records, but not able to get the desired result:
dataQuery = [BackendlessDataQuery new];
queryOptions = [QueryOptions new];
queryOptions.related = [NSMutableArray arrayWithArray:@[@"beacons",@"beacons.LocalNotify"]];
dataQuery.whereClause = [NSString stringWithFormat:@"beacons.majorVersion = \'%@\' AND beacons.minorVersion = \'%@\' AND beacons.LocalNotify.notifyStatus = 1 AND beacons.LocalNotify.StartDate <= \'%@\' AND beacons.LocalNotify.ExpirationDate >= \'%@\'",becMajor, becMinor, [NSDate date], [NSDate date]];
dataQuery.queryOptions = queryOptions;
I am able to get the child records but the where clause condition doesn’t work for child table “beacons.LocalNotify.notifyStatus = 1 AND beacons.LocalNotify.StartDate <= ‘%@’ AND beacons.LocalNotify.ExpirationDate >= ‘%@’”
So, using two-step relations retrieval will solve the problem?
Actually, I am trying to get the records from child tables based on where clause query. Table Retailers has one to many relation with table Beacons and table Beacons has one to many relation with table BeaconLocalNotify.
You should test your where clause in REST Console anyway. Try this:
Open Backendless console and select your app
Click Data and then click the Retailer table
Enter your where clause in the search field and make sure the SQL Search toggle is set to ON
You need to make sure the search query is correct and you're getting expected data.