【phpMyAdmin】Update

phpMyAdmin】Update

 

例:

1.Update前

 

テーブル名 : test_tbl

 

id name birth

1 a 2000-01-01

2 b 2000-01-02

3 c 2000-01-03

4 d 2000-01-04

 

2.Updateデータ方法1

個別でUpdate

update `test_tbl` SET `birth` = '2000-01-11' WHERE `id` = 1


update `test_tbl` SET `birth` = '2000-01-12' WHERE `id` = 2


update `test_tbl` SET `birth` = '2000-01-13' WHERE `id` = 3

 

 3.Updateデータ方法2

複数Update

 update `test_tbl` SET


`birth` =
case `id`
WHEN 1 THEN '2000-01-11'
WHEN 2 THEN '2000-01-12'
WHEN 3 THEN '2000-01-13'
END


WHERE `id` IN (1,2,3);

 

 4.Updateデータ方法3

複数Update

update `hoehoe_tbl` SET


`name` =
case `id`
WHEN 1 THEN 'aa'
WHEN 2 THEN 'bb'
WHEN 3 THEN 'cc'
END


`birth` =
case `id`
WHEN 1 THEN '2000-01-11'
WHEN 2 THEN '2000-01-12'
WHEN 3 THEN '2000-01-13'

END


WHERE `id` IN (1,2,3);

 

参考URL

https://qiita.com/Morinikiz/items/f3aece83c4010bb771a4

 

http://katzplus.com/centos-6/mysql/%E8%A4%87%E6%95%B0%E8%A1%8C%E5%90%8C%E6%99%82%E3%81%ABupdate%E3%81%97%E3%81%A6%E3%81%BF%E3%82%8B/