Mysql 在多个表上联接

Mysql 在多个表上联接,mysql,sql,Mysql,Sql,我有两个SQL表: select * from operation; id | name ----+-------------------- 1 | Account add 2 | Account edit select * from role_operation; id | role | operation ----+----------+----------- 1 | admin | 1 2 | operator | 1

我有两个SQL表:

select * from operation;
id |        name
----+--------------------
1 | Account add
2 | Account edit

 select * from role_operation;
 id |   role   | operation
----+----------+-----------
  1 | admin    |        1
  2 | operator |        1
  3 | admin    |        2
操作表中的
id
列与角色操作中的
operation
列链接。(外键)。如何获取操作
name=Account add

我尝试了
从role\u operation中选择role\u operation.role,operation.name对role\u operation进行内部连接操作。operation=operation.id

但这将提供在角色操作表的操作字段中存在操作id的所有行。

使用where

SELECT role_operation.role, operation.name 
FROM role_operation 
INNER JOIN operation ON role_operation.operation=operation.id
where  operation.name = 'Account add';
在哪里使用

SELECT role_operation.role, operation.name 
FROM role_operation 
INNER JOIN operation ON role_operation.operation=operation.id
where  operation.name = 'Account add';

您忘记了WHERE子句您忘记了WHERE子句请添加一些文字解释您的解决方案如何/为什么工作。请添加一些文字解释您的解决方案如何/为什么工作。