Reputation: 12262
I need to go to two tables to get the appropriate info
exp_member_groups
-group_id
-group_title
exp_members
-member_id
-group_id
I have the appropriate member_id
So I need to check the members table, get the group_id, then go to the groups table and match up the group_id and get the group_title from that.
Upvotes: 1
Views: 234
Reputation: 72880
If there is always a matching group, or you only want rows where it is, then it would be an INNER JOIN
:
SELECT g.group_title
FROM exp_members m
INNER JOIN
exp_member_groups g
ON m.group_id = g.group_id
WHERE m.member_id = @member_id
If you want rows even where group_id doesn't match, then it is a LEFT JOIN
- replace INNER JOIN
with LEFT JOIN
in the above.
Upvotes: 1
Reputation: 147264
SELECT g.group_title
FROM exp_members m
JOIN exp_member_groups g ON m.group_id = g.group_id
WHERE m.member_id = @YourMemberId
Upvotes: 2
Reputation: 15265
INNER JOIN:
SELECT exp_member_groups.group_title
FROM exp_members
INNER JOIN exp_member_groups ON exp_members.group_id = exp_member_groups.group_id
WHERE exp_members.member_id = @memberId
Upvotes: 4