H I O X INDIA
MySQL Tutorial
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Mysql Tutorial
Introduction
How to Install
Database
Datatypes
Tables
INSERT
SELECT
UPDATE
DELETE
Operators
Functions
Ask Your Doubts
Feedback





Type Conversion in Expressions


Topic

What is meant by Type Conversion?
How type conversion and casting takes place?
How to convert string to integer and integer to string?



Explanation


Type Conversion :

    Type conversion takes place when operators are used with different types of operands in an expression. Some conversions are done implicitly and some need explicit conversions.

    In MySQL the numbers are converted to strings and sometimes strings to numbers depending upon the condition.

    Let us consider an example for converting a string to an integer.

mysql> Select 1+'11';
 --> 12
    Here the string '11' is converted to a number and the result of the expression is also a number.

    Lets see another example for converting an integer to a string.
mysql> select concat(1, ' HIOX');
 --> '1 HIOX'
    We can convert or casting a number to a string explicitly. Here we use CAST() or CONCAT() function.

mysql> select 12, cast(12 as char);
 --> 12, '12'
mysql> select 12, concat(12);
 --> 12, '12'


others


        MySQL is the most popular open source database Management system. Being a open source anyone can use and change the software for their needs. Hope you enjoy this tutorial. We welcome your Valuable feedbacks or suggestions on this MySQL tutorial. This is a copyright content.


privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links