我无法构建此查询,它会返回表中的所有行。 我想只选择这个记录,其中catid在1到20之间,只有这些记录的间隔为30天。 将两个查询分开工作。
- SELECT * FROM `movies` WHERE uploaded >= DATE_SUB(NOW()
- SELECT id FROM `movies` WHERE (catid BETWEEN 1 AND 20)
带子查询的整个查询:
SELECT * FROM `movies` WHERE uploaded >= DATE_SUB(NOW(), INTERVAL 30 DAY) IN(SELECT id FROM `movies` WHERE (catid BETWEEN 1 AND 20))
答案 0 :(得分:4)
SELECT * FROM `movies`
WHERE uploaded >= DATE_SUB(NOW(), INTERVAL 30 DAY)
AND catid BETWEEN 1 AND 20