Posted on

MySQL Select Case

Sintaks :

CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result …] [ELSE result] END

Contoh :

select
CASE bulan when “01″ then “Januari”
when “02″ then “Februari”
when “03″ then “Maret”
when “04″ then “April”
when “05″ then “Mei”
when “06″ then “Juni”
when “07″ then “Juli”
when “08″ then “Agustus”
when “09″ then “September”
when “10″ then “Oktober”
when “11″ then “November”
when “12″ then “Desember”
END
from kalender where tahun = “2005″ order by bulan

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s