我试图按转换后的列排序,但 psql 返回错误:
SELECT * FROM table ORDER BY CONVERT(col1 USING utf8_to_iso_8859_2);
ERROR: syntax error at or near "USING" LINE 1: SELECT * FROM table ORDER BY CONVERT(col1 USING utf8... ^
*** Error ***
ERROR: syntax error at or near "USING" SQL state: 42601
我以前看到这个函数用过 liked this 并且它也在文档中,所以我不明白为什么我会收到这个错误。我错过了什么吗?
最佳答案
您可能想使用:
CONVERT(col1, 'iso-8859-2')
将 col1(文本)转换为 iso-8859-2(bytea),假设您的数据库存储为 utf-8。 convert
、convert_to
和 convert_from
显示在表 9-6 中:http://www.postgresql.org/docs/9.1/static/functions-string.html
关于sql - PostgreSQL 转换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9115455/