开发者

update column using where clause a same field's multipul values

开发者 https://www.devze.com 2023-01-29 22:24 出处:网络
Dear all, i need to update a table using same filed\'s multiple value. Let: update test_table set column1=123 where column2=100,200,300......

Dear all, i need to update a table using same filed's multiple value. Let: update test_table set column1=123 where column2=100,200,300...... I mean column 2 have multiple values.Now how i write the query?? Please help me.开发者_运维百科


try

update test_table set column1=123 where column2 IN(100,200,300)

look here for a tutorial: http://www.webdevelopersnotes.com/tutorials/sql/tutorial_mysql_in_and_between.php3


If you mean that the match should happen where column2's value is one of the items in your list, use:

UPDATE test_table 
    SET column1=123 
        WHERE column2 IN (100,200,300, ...)


use FIND_IN_SET

FIND_IN_SET("id",test_table.column2)
0

精彩评论

暂无评论...
验证码 换一张
取 消