select * from workers where id = uid and age = uage` -- sql1
select uid,uage from users where uage>20` -- sql2
我想使用sql2
作为sql1
的条件,即uid
和uage
中使用的sql1
来自 sql2
。
最佳答案
您可以连接两个表:
SELECT w.*
FROM workers w
INNER JOIN users u
ON w.id = u.uid AND w.age = u.uage
WHERE u.uage > 20
关于mysql - 我该如何完成这个查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10637359/