1

I am trying to update rows in mysql but I have to use for loop for multiple update for single value mysql query is

update table set column1='100' where id =1
update table set column1='100' where id =6
update table set column1='100' where id =14

I am using for loop for running query multiple times with different id, I want to run single query for update all rows. Is that possible?

i want to do something like that

  update table set column1='100' where id=1,6,14;
4

2 に答える 2

2

使用するIN()

update table 
set column1='100' 
where id in (1,6,14)

またOR

update table 
set column1='100' 
where id = 1 OR id = 6 OR id = 14
于 2015-01-16T06:30:19.123 に答える
1

IN()演算子を使用する

update table_name SET field_name='101'
where id IN(1,2,7,9) 
于 2015-01-16T06:38:47.440 に答える