Friday, December 18, 2015

[google-cloud-sql-discuss] Re: converter integer para string consulta

I think CAST (or CONVERT) is what you need.

Here is an example:

mysql> CREATE TABLE t(i INT);
Query OK, 0 rows affected (0.50 sec)

mysql> INSERT INTO t VALUES (1), (2);
Query OK, 2 rows affected (0.24 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> SELECT CAST(i AS CHAR) FROM t;
+-----------------+
| CAST(i AS CHAR) |
+-----------------+
| 1               |
| 2               |
+-----------------+
2 rows in set (0.09 sec)

mysql> 

[1] http://dev.mysql.com/doc/refman/5.6/en/cast-functions.html

-- Razvan ME


On Thursday, December 17, 2015 at 9:01:56 AM UTC-8, Danny Xu wrote:
Hi,

You could add a new field to the table. Copy the original integer field as string type to the new field. Delete the old field in integer. Then you can use the new field in the future.

On Wednesday, December 16, 2015 at 2:39:15 PM UTC-8, Gilson Rauschkolb wrote:
Boa Noite,

Pessoal estou com um dilema, tenho um campo em uma tabela que é integer, e na consulta gostaria de substituir o valor por um texto.

como faço isso?

Obrigado

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/e1aa0010-21f3-450b-b745-3f5bb781336e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment