Coverter Int in Vachar - Mysql

Asked

Viewed 50 times

0

Personal talk Good afternoon.

I’m making a list of columns in my Files table. And I needed to convert a "Id_folder" column of the INT type into Varchar at the time I Brought the data after the query in the database. But I don’t know how to convert. Someone could help me

my query code

 SELECT DISTINCT id_pasta, nome, id_usuario, de, ate
FROM arquivos 
WHERE ate between '2020-06-30' and '2020-08-15'
ORDER BY ate;
  • Tried to use the function cast?

  • Yes, I did a test only with the column ID_PASTA but only returns me only the number Integer.

1 answer

0

You will have to convert using the function CAST or CONVERT for the datatype CHAR . There is no conversion to VARCHAR .

For example :

SELECT DISTINCT CAST(id_pasta as CHAR(50)), nome, id_usuario, de, ate
FROM arquivos 
WHERE ate between '2020-06-30' and '2020-08-15'
ORDER BY ate;

 SELECT DISTINCT CONVERT(id_pasta as CHAR(50)), nome, id_usuario, de, ate
FROM arquivos 
WHERE ate between '2020-06-30' and '2020-08-15'
ORDER BY ate;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.