0

我在使用日期而不是子查询时看到了对此的回复。我有以下

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) 

我希望结果不具有包容性。不幸的是,我对任何 < > = 都没有任何运气

4

2 回答 2

2

我所知道的最好的,a BETWEEN b and c是语法糖b <= a and a <= c,即总是包容的。要使其独占,请将其重写为b < a and a < c.

于 2013-04-27T18:03:00.627 回答
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
于 2013-04-27T18:04:31.773 回答