Where relation.objectId not equal to objectId

Hi guys,

I need to get users with a certain role and if following or not.

case 1. where following.objectId = ‘D5C035C8-365B-452C-B582-122EAD1C6F23’ AND role = ‘Jockey’

returns the ‘jockey’ the user ‘D5C035C8-365B-452C-B582-122EAD1C6F23’ is following as expected.

case 2. where following.objectId != ‘D5C035C8-365B-452C-B582-122EAD1C6F23’ AND role = ‘Jockey’

returns all jockeys, not just the ones the user isn’t following. What would be the correct where clause in this case?

My application ID is 53D8E0B3-CAB5-DBDC-FF1F-CD01F1E14900.

Thanks in advance.

Hi @Marco_De_Freitas,

could you please clarify second case - what do you receive and what do you expected to receive?
I don’t quite understood desired result.


Hi Victor

Case 1 - get users that are alreadyfollowed by user.
Case 2 - get users that are not being followed by user : but I get all users including ones who are followed by the user. So I only need users with a specific role who the user isn’t following.

Hope that makes sense.

Cheers, thanks.

Hello @Marco_De_Freitas, it is a good question.

First of all, let me explain why do you get such result.
Column following is 1:many relation and you have user(at least one) that have follower with id D5C035C8-365B-452C-B582-122EAD1C6F23 and also with other id. So when you ask backendless give me records that contains D5C035C8-365B-452C-B582-122EAD1C6F23 it will join tables and returns the only user with particular id. But if you say give me the records that does not equals D5C035C8-365B-452C-B582-122EAD1C6F23 it still join tables end exclude record that has the id, and as your user has more then one relation you will see it.

So the simplest way to implement case 2 is to execute 2 queries:

  1. where following.objectId = 'D5C035C8-365B-452C-B582-122EAD1C6F23' AND role = 'Jockey'
  2. where objectId not in (list from the first case)
1 Like