Update multiple rows at once with different conditions.

sebagai contoh – sempena worldcup 2010

Table – gol

negara kekerapan_gol

brazil 10
portugal 11
japan 8

so now kita mau update table gol serentak, bley guna mysql case statement.

[quote]

UPDATE gol SET

kekerapan_gol = CASE
WHEN negara = ‘brazil’ THEN ‘$jumgolbarubrazil’
WHEN negara = ‘portugal’ THEN ‘$jumgolbaruportugal’
WHEN negara = ‘japan’ THEN ‘$jumgolbarujapan’
ELSE kajian END

[/quote]

This article was written by matn0t.