我正在建立一个检查SSL地址连接的系统。为此,我使用两个表:
ssllist
- id
- dnsname
- active (0 or 1)
sslresult
- id
- ssllist_id
- starttime
- result (0 or 1)
默认情况下,我的系统每30分钟检查一次ssllist中的所有条目,但我也希望它每分钟检查符合这些规则的条目:
- Active=1
AND(
- no results of this entry in sslresult
OR
- had an error in the last half hour (result=0)
OR
- did not have ANY results in the last half hour
)
因此,我使此查询符合前3条规则:
SELECT
ssllist.id as id,
ssllist.dnsname
FROM ssllist
LEFT JOIN sslresult
ON ssllist.id = sslresult.ssllist_id
WHERE
ssllist.active=1
AND
(
(sslresult.result = 0 AND sslresult.starttime > (UNIX_TIMESTAMP() - 1800)
OR
sslresult.ssllist_id is null
)
GROUP BY id
但是我不知道如何添加最后一个“where”语句,所以“获取所有ssllist.id的过去半小时内没有sslresult”。
怎么做?