我想创建一个 SELECT 查询,它将以 integer
格式作为 text
格式返回列中的数字 - 我可以在 SQLite 中执行吗?
最佳答案
SQLite 支持 CAST和:
Casting an INTEGER or REAL value into TEXT renders the value as if via sqlite3_snprintf() except that the resulting TEXT uses the encoding of the database connection.
所以你可以这样做:
select cast(some_integer_column as text) from some_table;
或者,根据您要执行的操作,您可以将数字视为字符串并让 SQLite 强制转换它认为合适的类型:
select some_int || ' pancakes' from some_table;
select some_int || '' from some_table;
关于sql - 在 SQLite 的 SELECT 查询中将整数转换为文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12419693/