我未能在 mysql 中运行查询。故意不想做select id from roles
...
查询
select rtu.role_id
from roles r
where id =(select role_id
from roles_to_user rtu
where user_id=1)
错误
ERROR 1054 (42S22): Unknown column 'rtu.role_id' in 'field list'
描述角色到用户:
+---------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------+------+-----+---------+-------+
| user_id | int(11) | NO | PRI | NULL | |
| role_id | int(11) | NO | PRI | NULL | |
+---------+---------+------+-----+---------+-------+
描述角色:
+-------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(80) | NO | | NULL | |
+-------+-------------+------+-----+---------+----------------+