Reputation: 414
I'm querying a pgsql DB to find rows that have certain keys in an hstore field:
select DISTINCT
from (select id, exist(data, ‘exercise_quiz’) key_exists
from user_tracking) x
where key_exists = true;
It works fine, but I need to print the IDs of the corresponding rows it returns. Can I do this with this command?
Upvotes: 2
Views: 258
Reputation: 121594
Use the operator hstore ? text
(does hstore contain key?):
select id
from user_tracking
where data ? 'exercise_quiz';
Upvotes: 2