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.
亲爱的大家,我需要使用同一个文件的多个值来更新一个表。让:更新test_table set column1=123,其中column2=100,200,300…我的意思是列2有多个值。现在我如何编写查询?请帮助我。
3 个解决方案
#1
3
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
请看这里的教程:http://www.webdevelopersnotes.com/tutorials/sql/tutorial_mysql_in_and_between.php3
#2
1
If you mean that the match should happen where column2
's value is one of the items in your list, use:
如果您的意思是匹配应该发生在column2的值是您列表中的一个项目时,请使用:
UPDATE test_table
SET column1=123
WHERE column2 IN (100,200,300, ...)
#3
0
use FIND_IN_SET
使用FIND_IN_SET
FIND_IN_SET("id",test_table.column2)
#1
3
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
请看这里的教程:http://www.webdevelopersnotes.com/tutorials/sql/tutorial_mysql_in_and_between.php3
#2
1
If you mean that the match should happen where column2
's value is one of the items in your list, use:
如果您的意思是匹配应该发生在column2的值是您列表中的一个项目时,请使用:
UPDATE test_table
SET column1=123
WHERE column2 IN (100,200,300, ...)
#3
0
use FIND_IN_SET
使用FIND_IN_SET
FIND_IN_SET("id",test_table.column2)