I’m trying to select users for listing, and I want to be able to select users based on groups. I have the following db query (don’t laugh, got to start somewhere

).
SELECT u.username, a.*, g.*, n.*
FROM `db1`.modx_web_users u
INNER JOIN `db1`.modx_web_user_attributes a ON u.id = a.id
INNER JOIN `db1`.modx_web_groups g ON u.id = g.webuser
INNER JOIN `db1`.modx_webgroup_names n ON g.webgroup = n.id
ORDER BY username LIMIT 5
It works, but if a user is in more than one group he/she gets listed more than once.
If I specify WHERE = ’GroupName’ the user only get listed once, but I don’t always want to specify a group. I only want the user to be listed one time.
If someone could suggest how to do I’d be a happy puppy!
Also, if someone want to suggest me how to write this sql in a better way, please go ahead!