1. unicserv
  2. General
  3. Thursday, February 20 2014, 11:34 AM
Hello,

I have troubles building a sql command that do the following:

I have a module that should display the only the users that are simultaneous in 2 distinctive usergroups.

I have tried to put into Custom SQL WHERE field:

group_id=205 AND group_id=21 No success
(group_id=205 AND group_id=21) No succes either

The module display correctly only if i do
group_id=205
or
group_id=21

how do i compose complex filter using AND, OR, and parenthesis operators?

I'm have no sql complex knowledge about sql sintax so an complex filter example containing () will help me much more.

Later edit:
with OR operator the module is working also
group_id=205 OR group_id=21 is displaying a list of users
but i need AND operator and some paranthesis for building complex sql interogation
I need to display only the users that are simultaneous in several user groups
Accepted Answer
admin Accepted Answer
Admin
Sorry for wait, it took me a long time to create it.
It seems easy but is really rather complex

here the CUSTOM SQL
user_id IN (SELECT user_id FROM #__user_usergroup_map WHERE group_id IN (21,205) GROUP BY user_id HAVING count(user_id)=2)


example with 3 user groups
user_id IN (SELECT user_id FROM #__user_usergroup_map WHERE group_id IN (2,7,9) GROUP BY user_id HAVING count(user_id)=3)
  1. more than a month ago
  2. General
  3. # Permalink
unicserv Accepted Answer
I'm stupid, i realised that
group_id=205 AND group_id=21
cannot have any result so the module is working correctly.
But i still don't know how to achieve my filtering for people that are simultaneous in several usergroups.
Any help will be appreciated.
  1. more than a month ago
  2. General
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.
Sorry, the discussion is currently locked. You will not be able to post a reply at the moment.