Wednesday, September 4, 2013

MySql cast or convert data(integer, float, double, decimal, date, etc...) as character/string

Fiddle link

You will need to cast or convert as a CHAR datatype, there is no varchar datatype that you can cast/convert data to:
select CAST(id as CHAR(50)) as col1 from t9;

select CONVERT(id, CHAR(50)) as colI1 from t9;
select CAST(amount AS DECIMAL(10, 2)) AS amount FROM t9; 

No comments:

Post a Comment