我对SQL很新,因此这听起来很愚蠢。 我有两个问题。
首先
SELECT
Tap_Back.*
FROM Tap_Back
WHERE Tap_Back.time > '2018-01-23'
第二
SELECT
readingdates.readdate
FROM readingdates
WHERE readingdates.readdate <= CURRENT_DATE()
ORDER BY readingdates.readdate DESC
LIMIT 1
因此,我不想在First中对日期进行硬编码,而是希望从另一个表中读取它。
答案 0 :(得分:0)
SELECT Tap_Back.*
FROM Tap_Back
WHERE Tap_Back.time > (SELECT readingdates.readdate
FROM readingdates
WHERE readingdates.readdate <= CURRENT_DATE()
ORDER BY readingdates.readdate DESC
LIMIT 1)
或我的偏好是
SELECT Tap_Back.*
FROM Tap_Back
WHERE Tap_Back.time > (SELECT min(readingdates.readdate)
FROM readingdates
WHERE readingdates.readdate <= CURRENT_DATE())