Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何从任何hstore值中选择一行?_Sql_Postgresql_Hstore - Fatal编程技术网

Sql 如何从任何hstore值中选择一行?

Sql 如何从任何hstore值中选择一行?,sql,postgresql,hstore,Sql,Postgresql,Hstore,我在PostgreSQL(9.5)数据库中有一个表Content,其中包含列title。title列是一个hstore。这是一个hstore,因为标题被翻译成不同的语言。例如: example=# SELECT * FROM contents; id | title | content | created_at

我在PostgreSQL(9.5)数据库中有一个表
Content
,其中包含列
title
title
列是一个
hstore
。这是一个
hstore
,因为
标题
被翻译成不同的语言。例如:

example=# SELECT * FROM contents;
 id |                    title                    |                    content                     |         created_at         |         updated_at         
----+---------------------------------------------+------------------------------------------------+----------------------------+----------------------------
  1 | "de"=>"Beispielseite", "en"=>"Example page" | "de"=>"Beispielinhalt", "en"=>"Example conten" | 2016-07-17 09:20:23.159248 | 2016-07-17 09:20:23.159248
    (1 row)
我的问题是,我如何选择
内容
,其中
标题
包含
示例页面

SELECT * FROM contents WHERE title = 'Example page';
不幸的是,这个查询不起作用

example=# SELECT * FROM contents WHERE title = 'Example page';
ERROR:  Syntax error near 'p' at position 8
LINE 1: SELECT * FROM contents WHERE title = 'Example page';

您应该在where子句中使用like

SELECT * FROM contents WHERE title like '%Example page%';
希望它能帮助您。

函数
avals()
返回
hstore
列中所有值的数组。然后,您可以使用
any
与该数组匹配您的值:

select *
from contents 
where 'Example page' = any(avals(title))

title
是一个
hstore
列。您不能在
hstore
上使用
LIKE
是否可以强制转换为varchar数据类型?
错误:运算符不存在:hstore~~unknown