Support

  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.

Request Support

Support is currently Offline

Support Availability

Working days: Monday to Friday. The support staff is not available on weekends; in the most of cases tickets will not be answered during that time.

Reply time: Depending on the complexity of your support issue it's usually between a few minutes and 24 hours for paid members and about one week for free members. When we expect longer delays we will notify you.

Guidelines

Before you post: read the documentation and search the forums for an answer to your question.

When you post: include Site Details if you request a support (you can use the form below the reply in Site Details tab).

Auto Solved Question: If after a week the author of the post does not reply to a request by moderator, the question will be marked as resolved.

Language: only English

Search Users

Easy Profile® is not affiliated with or endorsed by Open Source Matters or the Joomla Project. Joomla is Free Software released under the GNU/GPL License.