我有一张表,我正在尝试更新范围记录,我尝试了多种方法,没有运气。这是我尝试过的脚本。
UPDATE va_categories SET is_showing = '1' WHERE category_id IS BETWEEN 1076 AND 1412;
UPDATE va_categories SET is_showing = '1' WHERE category_id > '1076' < '1412';
category_id是一个整数字段。
我很感激帮助,在这里敲我的头。
答案 0 :(得分:17)
试试这个
UPDATE va_categories SET is_showing = '1' WHERE category_id BETWEEN 1076 AND 1412;
或
UPDATE va_categories SET is_showing = '1' WHERE category_id > 1076 AND category_id < 1412
答案 1 :(得分:2)
以下是MySQL中范围的指令:
SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
因此,这有效:
UPDATE va_categories SET is_showing = '1' WHERE category_id BETWEEN 1076 AND 1412;
答案 2 :(得分:0)
摆脱IS
中的IS BETWEEN
。或者使用WHERE category_id > 1076 AND category_id < 1412
:
UPDATE va_categories SET is_showing = '1' WHERE category_id BETWEEN 1076 AND 1412;
UPDATE va_categories SET is_showing = '1' WHERE category_id > 1076 AND category_id < 1412;