Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
该表request具有外键字段job和user. 我需要提取一个用户同时拥有job= 35 和job= 34 的行的行子集。
request
job
user
此查询是否正确完成工作?我相信是的。
SELECT * FROM `request` WHERE `job` = 35 AND `fulfilled` is NULL AND `user` IN (SELECT `user` FROM `request` WHERE `job` = 34 AND `fulfilled` is NULL )
SELECT user FROM request WHERE job IN (34,35) AND `fulfilled` is NULL GROUP BY user HAVING COUNT(DISTINCT job) = 2