Sql hstore:无法连接两个hstore值

Sql hstore:无法连接两个hstore值,sql,postgresql,hstore,Sql,Postgresql,Hstore,使用v9.3的Postgres新手希望利用hstore 当我尝试连接两个hstore值时,会出现一个奇怪的错误: SELECT p.properties->'name' || p.properties->'age' FROM people p where p.id=1; 错误是: ERROR: operator does not exist: text -> unknown LINE 1: select n.properties->'name' || n.proper

使用v9.3的Postgres新手希望利用
hstore

当我尝试连接两个
hstore
值时,会出现一个奇怪的错误:

SELECT p.properties->'name' || p.properties->'age' FROM people p where p.id=1;
错误是:

ERROR:  operator does not exist: text -> unknown
LINE 1: select n.properties->'name' || n.properties->'age' from n...
                                                   ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
我也试过了,没关系:

SELECT p.properties->'name'::text || p.properties->'age'::text FROM people p where p.id=1;
然而,我能做到

不能从同一个hstore中连接两个hstore值吗


感谢任何指点

您可以按原样使用CAST功能:

SELECT CAST(p.properties->'name' AS text) || CAST(p.properties->'age' AS text) FROM people p where p.id=1;

这就解决了问题。事实证明,您只需强制转换第二个和后续的hstore引用,第一个可以保持不变。奇怪的谢谢你的帮助!
SELECT CAST(p.properties->'name' AS text) || CAST(p.properties->'age' AS text) FROM people p where p.id=1;