我有下面的查询。我的目标是以某种方式排除4到14之间的条目,而不显示它们。
SELECT code, register, data
FROM code
WHERE code
BETWEEN 4
AND 14
ORDER BY code
只需在列code
之后使用NOT
。
SELECT code, register, data
FROM code
WHERE code NOT
BETWEEN 4
AND 14
ORDER BY code;
或者您也可以在列code
之前使用"NOT"
SELECT code, register, data
FROM code
WHERE NOT code
BETWEEN 4
AND 14
ORDER BY code;
看看这个SQLFiddle
参考。MySQL:expr不在最小值和最大值之间