Retrieving relation not working(Swift)

I have a table UserGroups and it has a one-many relation with users table. I am trying to fetch user records from UserGroups using the following code:

    let dataQuery = BackendlessDataQuery()


    dataQuery.whereClause = "UserGroups[users].email = \'\(email)\'"



    var error: Fault?

    let bc =, fault: &error)

    if error == nil {


        let contacts = bc.getCurrentPage()


        for theGroup in contacts as! [UserGroups]{






    else {

        print("Server reported an error: \(error)")


I am getting the following error: Server reported an error: Optional(FAULT = ‘1017’ [Invalid where clause. Specified Entity: UserGroups[users] is not related to lowerLevelEntity: UserGroups]

Can you please tell me if I am doing anything wrong?

Thank you

Is the relation column defined in the UserGroups table?

I got it to work. Thank you.

How ? please reply I got same problem…

Akash, Please investigate this doc, in particular, “Loading a Subset of Related Child Objects” section.

distance( 17.438975,78.4000716, geoPoint.latitude, geoPoint.longitude ) < km(1) and (ParkingLot[bike].availableSlots > 0 OR ParkingLot[car].availableSlots > 0)

availableSlots is column in Bike and Car table.
I want to load parking Lots where bike and car availableSlots are greater than 0.
ParkingLot table has one to one relation with Bike and Car table


I have a similar issue here. Could someone please, share the code for retrieving data including a where clause on the child object?


What API do you use to retrieve data? And what problem are you experiencing?


Hi , thank you for your responsek. To be honest I am essentially a beginner and I am stuck on this point.

My issue is using iOS API (swift).

I have a table called “solicitudes” as follows:

And I want ro retrieve all objects from this table where Usuario is a given BackendlessUser.

I coded like this:

static func listaEquiposPendienteAceptar(DTMID: String, completion: @escaping (Result< Peticiones, Error>) -> ()){
        let queryBuilder = DataQueryBuilder()
        queryBuilder.whereClause = "BDSolicitudes[Usuario].objectId = " + DTMID

    let dataStore =
    dataStore.find(queryBuilder:  queryBuilder, responseHandler: { resultados in
        let solicitudes = resultados as! [BDSolicitudes]
        if solicitudes.count > 0 {
            for sol in solicitudes{
                let pet = Peticiones(objectId: sol.objectId!, Usuario: sol.Usuario!.objectId!, Equipo: sol.Equipo!.objectId!)
            }, errorHandler: { fault in
                print("Error: \(fault.message ?? "")")


Hello @Alejandro_Cuartas_Fernandez,

Please try to change your whereClause:

queryBuilder.whereClause = "Usuario.objectId = 'XXX'"

and make sure you have the single quotes around the objectId.

More info about subqueries can be found here:


1 Like

Thank you, it does work now!!!