我正在查询 pgsql 数据库以查找 hstore 字段中具有某些键的行:
select DISTINCT
from (select id, exist(data, ‘exercise_quiz’) key_exists
from user_tracking) x
where key_exists = true;
它工作正常,但我需要打印它返回的相应行的 ID。我可以用这个命令来做到这一点吗?
最佳答案
使用运算符hstore ?文本
(does hstore contain key?) :
select id
from user_tracking
where data ? 'exercise_quiz';
关于postgresql - Postgres/hstore : how to get IDs of rows with certain key in their hstore field?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46333056/