【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