我有 3 个不同的表 .. 我将得到一个字符串作为输入,我必须从最后一个表中找出 emil。
这里输入的是'html'
mysql> select id from track where name LIKE 'html';
+------+
| id |
+------+
| 116 |
+------+
根据上面查询提供的id....
mysql> select name from resource where task='2' AND track ='116';
+------+
| name |
+------+
| 1005 |
+------+
根据上述查询提供的名称..
mysql> select email from users where id = '1005';
+--------+
| email |
+--------+
| pinhu |
+--------+
我想将这些查询合并为一个,所以有人可以帮助我构建查询吗。
最佳答案
select u.email
from users u
inner join resource r on u.id = r.name
inner join track t on r.track = t.id
where t.name = 'html'
and r.task='2'
关于mysql - 将 3 个不同的 mysql 查询合并为一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19853763/