How to update a range of records in Mysql

后端 未结 3 917
一向
一向 2020-12-29 16:02

I have a table that I am trying to update a range records, I have tried multiple methods with no luck. Here is the scripts I\'ve tried.

UPDATE va_categories          


        
相关标签:
3条回答
  • 2020-12-29 16:09

    Try this

    UPDATE va_categories SET is_showing = '1' WHERE category_id  BETWEEN 1076 AND 1412;
    

    or

     UPDATE va_categories SET is_showing = '1' WHERE category_id > 1076 AND category_id < 1412
    
    0 讨论(0)
  • 2020-12-29 16:21

    Here is the directive for range in MySQL:

    SELECT column_name(s)
    FROM table_name
    WHERE column_name BETWEEN value1 AND value2;
    

    Hence, this works:

    UPDATE va_categories SET is_showing = '1' WHERE category_id BETWEEN 1076 AND 1412;
    
    0 讨论(0)
  • 2020-12-29 16:25

    Get rid of the IS in IS BETWEEN. Or use 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;
    
    0 讨论(0)
提交回复
热议问题