我在使用日期时看到了对此的回复,但没有查看子查询。我有以下
SELECT *
FROM `TEST`
where `ID` BETWEEN
(SELECT `ID` FROM `TEST` WHERE `Home_Team`
REGEXP 'saturday|sunday|monday|tuesday|wednesday|thursday|friday'
order by ID asc LIMIT 1)
AND
(SELECT `ID` FROM `TEST` WHERE `Home_Team`
REGEXP 'saturday|sunday|monday|tuesday|wednesday|thursday|friday'
order by ID asc LIMIT 1,1)
我希望结果不具有包容性。不幸的是,我没有任何运气与< > =
答案 0 :(得分:2)
最好我知道,a BETWEEN b and c
是b <= a and a <= c
的语法糖,即总是包容性的。要使其独占,请将其重写为b < a and a < c
。
答案 1 :(得分:0)
ID
是整数吗?如果是这样,只需+1
和-1
:
SELECT *
FROM `TEST`
where `ID` BETWEEN
(SELECT `ID` FROM `TEST` WHERE `Home_Team`
REGEXP 'saturday|sunday|monday|tuesday|wednesday|thursday|friday'
order by ID asc LIMIT 1) + 1
AND
(SELECT `ID` FROM `TEST` WHERE `Home_Team`
REGEXP 'saturday|sunday|monday|tuesday|wednesday|thursday|friday'
order by ID asc LIMIT 1,1) - 1