MySQL – Casting String to other type


How to casting or convert a data type to the other with MySQL.
1. String to Double

SELECT
n,
CONVERT( n, DECIMAL(10,2) )
FROM tabel
Result :

n CONVERT( n, DECIMAL(10,2) )
19.8 19.80
2 2.00

2. String to Integer

SELECT
n,
CONVERT( n, SIGNED )
FROM tabel

n CONVERT( n, SIGNED )
19.8 19
2.16 2

Thanks, i hope helpfull😀

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 May 17, 2013, in mYsQL, MySQL Theory 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: