Hi @mark-piller
Sorry for make you misunderstanding.
I repeate my story:
My “Conversation” table has 1:N relations with “Users” table. Hence, in “Conversation” table, I have column “users” which were automatically created while adding the relation with “Users” table. Is this clear until now?
Now, I’m in the “Conversation” table. I want to find all the conversation records which contain my 2 users “Mark” and “Minh”. So I wrote the query like that:
DataQueryBuilder queryBuilder = DataQueryBuilder()
…relationsDepth = 2
…whereClause =
“type = ‘solo’ AND users LIKE ‘%Mark%’ AND users LIKE ‘%Minh%’ ”;
But I always get an empty array.
What’s worng in my query?
I don’t know if it clearer for you now, if not, please let me know.
And to anwser you question: In “users” column of “Conversation” table, we can find the “Mark” and “Minh” in the same record. Because, this column link to many users (1:N) with “Users” table.
@Vladimir_Yalovy I tried it but not working because the operation
“whereClause = “user.name = ‘Mark’ or user.name = ‘Minh’”” should be “whereClause = “user.name = ‘Mark’ AND user.name = ‘Minh’””
I need to find a record of conversation which contain Mark and Minh. If I use “or” operation, I will get more conversations than I expected, for example: Mark-Vladimir, Minh - Vladimir, Minh - Mark. Only Minh-Mark is my expected result.
Do you get my point?
Many thanks
Hey @Minh_Tuan_Vu ,
try this out:
Basically this is the same as @Vladimir_Yalovy suggested you, but with additional condition - type = 'Solo'
DataQueryBuilder queryBuilder = DataQueryBuilder()
…whereClause = “type = ‘Solo’ AND (users.name = ‘Mark’ OR users.name = ‘Minh’)”
… property = “name”
… property = “Count(users) as usersCount”
…groupBy = “users”
…having = “count = 2”
Cheers,
Stanislaw
@stanislaw.grin Thanks so much, It finally work for me.
I just used your query with Count(users) = 1.
Many thanks to @Vladimir_Yalovy @mark-piller and @stanislaw.grin for your supports
1 Like