Flow Control MySQL – IF


Dump

CREATE TABLE `users` (
`nama` varchar(255) NOT NULL,
`gender` enum(‘L’,’P’) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

insert  into `users`(`nama`,`gender`) values (‘Joe’,’L’),(‘Jane’,’P’);

Query :

SELECT *, CONCAT(IF(gender = “L”, “Pak “, “Bu “), nama )
AS fullName
FROM users

Hasil :

zzz

 

 

Thnks.2.Ria Coder

About blackphp

All about programming php, ajax, jquery, mysql, etc, tips n trick. Now, i'm concern in php programming with codeigniter framework n also training my design skill with photoshop or corel... wish me luck! ('o')

Posted on October 31, 2009, in mYsQL and tagged . Bookmark the permalink. Leave a comment.

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: