如何让 WHERE 子句检查 postgresql 列表中的项目?

How to have a WHERE clause check items in a list in postgresql?

我在 postgresql 中有一个数据库 table,一些字段包含列表。

这是 select 查询结果的示例。

(2, u'osgb1000001786024039', 10053, 1, u'2001-11-07', [u'Land', u'Buildings'], ...)

您可以看到第六个字段(称为 'theme')有一个包含单个项目的列表。

我的问题是如何编写 WHERE 子句来检查该列表中的项目?

我试过:

SELECT * FROM os_mm.topographicarea
WHERE 'Buildings' IN theme

给出:

syntax error at or near "theme" LINE 2: WHERE 'Land' IN theme

显然这不起作用,那么我缺少什么命令或语法?

试试这个

SELECT * FROM os_mm.topographicarea
WHERE 'Buildings' = ANY (theme)

另见 postgresql documentation