June 15, 2010

Update multiple rows at once with different conditions.

by Matnet @ 9:59 am in WWW

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.

UPDATE gol SET

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


Comments
* Name


* Email Address (will not be published)


Site



*Image Validation (?)

Comments

HTML: NO


:: Shout Me ::



:: About Me ::



They call me : Yachiru
Name : Yachiru Kusajishi
Birthday : February 12
Working Field : Shinigami lieutenant - 11th Division
E-mail : matnet80 [at] yahoo [dot] com


:: Calendar ::

February 2012
S M T W T F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29