Miquel
Miquel

Reputation: 482

How to convert a numeric variable to a character variable in SELECT statement (MySQL)

SELECT *
   variable1,
   variable2,
   variable3,
   variable4
FROM table

I wanna transform the variable1 from a numeric variable to a character variable, and I'm trying this options:

SELECT *
   variable1 AS CHAR(variable1),
   variable2,
   variable3,
   variable4
FROM table

And I'm trying this other code:

SELECT *
   variable1 AS CONVERT(variable1, CHAR),
   variable2,
   variable3,
   variable4
FROM table

But it seems that's not the correct syntax.

Any idea?

Upvotes: 0

Views: 356

Answers (1)

Felipe Sanchez
Felipe Sanchez

Reputation: 59

SELECT 
   CONVERT(variable1,CHAR) AS variable1,
   variable2,
   variable3,
   variable4
FROM table

Upvotes: 1

Related Questions