First time posting here, please feel free to smack me upside the head if I perform a faux pas.
However, recently I decided to take up building up a page for my World of Warcraft guild (i've build a few pages for MMORPG guilds prior). I've used them as something to help build and broaden my knowledge, making each one better and better.
With this latest one, my intent was to create a "unified login" and essentially utilize phpBB2's authentication as well as the forum Usergroups to create authentication levels and thus "Member" and "Officer" access.
That part was no sweat, however the next step was creating a Roster page. For this I have built my own table containing my own fields I want to list on this page. One of the fields I have is "phpbb_id" in which I store the phpbb user_id of whom this roster profile entry belongs to.
My original intent was to then query the user_groups table of phpBB2 for a list of all "active" members and officers and only pull the rows from my own table that matched those phpbb_id's.
(the user_group, for those unaware, is just three fields. "user_id", "user_pending", and the "group_id" in which has been given access)
In essence I have this query:
mysql> select * from vantage_roster r, TSBphpbb_user_group g WHERE r.phpbb_id = g.user_id AND (g.group_id = 3 OR g.group_id = 4) ORDER BY name;
group_id 3 = Members, group_id 4 = Officers.
TSBphpbb_user_group = phpBB2's user_group table
vantage_roster = my own table for storing "profiles".
This works as expected with the query, however the problem is that All Officers (group 4's) are ALSO in the usergroup Members (group 3). So Officers appear twice in this query. I *do* want to retain the group_id found in this query so I can parse it into "officer" or "member" on my roster page, however I want group 4's row to take precedence over group 3's row. I was attempting to look for a way to tell the query to not allow duplicate rows of the same "id" (while also providing all other row data), but to no avail.
My question is (hopefully I was concise enough in my description) can what I wish to be done be accomplished through a single Query? Or must I go to multiple queries and or spill over into PHP parsing of the results?
Is returned, but I wish to have only one row returned per "id" of my table, having group_id 4 taking precedence over group_id 3.
Again, my apologies if i'm coming off like an ignorant, but any help or recommendations would be much appreciated.
-Brian