Here’s what I’m looking for: "List of users and their roles where role id = 4 or 5 or 6;
mysql> SELECT List of users in role 4, 5 or 6;
+-----+------------------+
| rid | r.name | u.name |
+-----+------------------+
|5 | editor | Bob |
|5 | editor | Randy |
|5 | editor | Jeff |
|5 | editor | Susan |
|4 | manager | Sara |
}6 | writer | Bob |
|6 | writer | Susan |
+-----+---------+--------+
7 rows in set (0.00 sec)
Here are the tables I’m working with:
mysql> describe users;
+-------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+-------+
| uid | int(10) unsigned | NO | PRI | 0 | |
| name | varchar(64) | NO | UNI | | |
+-------+------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> describe users_roles;
+-------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+-------+
| uid | int(10) unsigned | NO | PRI | 0 | |
| rid | int(10) unsigned | NO | PRI | 0 | |
+-------+------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> describe role;
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| rid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(64) | NO | UNI | | |
+-------+------------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
Thanks!