myBlog

MySQL Select Case

on October 19, 2011

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

Advertisements

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: