是否可以为查询的IN部分定义一个范围,像这样
SELECT job FROM mytable WHERE id IN (10..15);
代替
SELECT job FROM mytable WHERE id IN (10,11,12,13,14,15);
您不能,但可以使用 BETWEEN
BETWEEN
SELECT job FROM mytable WHERE id BETWEEN 10 AND 15
请注意,这BETWEEN是包含性内容,并且将包含ID为10和15的项。
如果不想包含,则必须退回到使用>and <运算符。
>
<
SELECT job FROM mytable WHERE id > 10 AND id < 15