Postgres的新手,使用v9.3,想要利用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;
但是,我可以做
SELECT p.properties->'name' FROM people p where p.id=1;
SELECT p.properties->'age' FROM people p where p.id=1;
是否无法将两个hstore值连接到同一个hstore中?
任何指示赞赏!
答案 0 :(得分:3)
您可以按原样执行 CAST 功能:
SELECT CAST(p.properties->'name' AS text) || CAST(p.properties->'age' AS text) FROM people p where p.id=1;