converter integer para string consulta

32 visningar
Hoppa till det första olästa meddelandet

Gilson Rauschkolb

oläst,
16 dec. 2015 17:39:152015-12-16
till Google Cloud SQL discuss
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

Danny Xu

oläst,
17 dec. 2015 12:01:562015-12-17
till Google Cloud SQL discuss
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.

Razvan Musaloiu-E.

oläst,
18 dec. 2015 17:45:382015-12-18
till Google Cloud SQL discuss
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> 


-- Razvan ME

Gilson Rauschkolb

oläst,
18 dec. 2015 17:54:192015-12-18
till google-cloud...@googlegroups.com

Thank your all

----
Cordialmente,
Gilson Luiz Rauschkolb

--
You received this message because you are subscribed to a topic in the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-cloud-sql-discuss/dfDzqSaDhH4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-cloud-sql-d...@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.
Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden