我可以在这两个条件下进行一个查询吗?如果是的话,我应该挖掘哪种方式?
SELECT c.ID, c.DateEnd FROM conference c WHERE DateEnd = DATE_ADD(CURDATE(),INTERVAL 1 DAY)
SELECT a.ID, a.IDConf FROM application a GROUP BY a.IDConf HAVING COUNT(a.IDConf) >= 2
最佳答案
如果只想联接HAVING COUNT(a.IDConf) >= 2
的结果,则可以在子选择上使用内部联接
SELECT c.ID, c.DateEnd
FROM conference c
INNER JOIN (
SELECT a.ID, a.IDConf
FROM application a
GROUP BY a.IDConf
HAVING COUNT(a.IDConf) >= 2
) t ON c.ID=t.IDConf
WHERE c.DateEnd = DATE_ADD(CURDATE(),INTERVAL 1 DAY)