converter integer para string consulta

已查看 32 次
跳至第一个未读帖子

Gilson Rauschkolb

未读,
2015年12月16日 17:39:152015/12/16
收件人 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

未读,
2015年12月17日 12:01:562015/12/17
收件人 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.

未读,
2015年12月18日 17:45:382015/12/18
收件人 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

未读,
2015年12月18日 17:54:192015/12/18
收件人 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.
回复全部
回复作者
转发
0 个新帖子