Cast Functions


There are only two cast functions, cast() and convert() . They do the same thing with slightly different syntaxes. Cast functions perform typecasting ”that is, they convert results from one type (for example, signed integer) to another (for example, char).

The prototypes are as shown here:

 
 cast(  expression  AS  type  ) convert(  expression, type  ) 

The cast() function is ANSI compliant, and convert() is ODBC compliant.

Valid types are BINARY , CHAR , DATE , DATETIME , SIGNED (INTEGER) , and UNSIGNED (INTEGER) .

Most casting in MySQL happens automatically when needed; for example, if feeding numbers into a string function, they will automatically be cast as strings.



MySQL Tutorial
MySQL Tutorial
ISBN: 0672325845
EAN: 2147483647
Year: 2003
Pages: 261

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net