我可以用这两个条件进行一次查询吗?如果是的话,我应该挖哪个方式?
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
答案 0 :(得分:0)
您可以使用左连接。试试这个:
SELECT c.ID, a.ID a_ID, c.DateEnd
FROM conference c LEFT JOIN application a
ON c.ID=a.IDConf
WHERE DateEnd=DATE(DATE_ADD(CURDATE(),INTERVAL 1 DAY))
GROUP BY c.ID, a.ID
HAVING COUNT(a.IDConf)>=2;
有关使用联接的见解,请参阅MySQL Join Made Easy。
答案 1 :(得分:0)
如果您只想加入/public
的结果,可以在子选择中使用内部联接
HAVING COUNT(a.IDConf) >= 2