how to select just red area i have a data which is in Hstore form so i want to select a specific key and value from data and then delete them, as i use this query it is find all rows which this key and value exist on it but i want those rows which is only involve this key and value not all
select * from topdog where tags @> 'created_by=>JOSM'
thanks
2 Answers 2
Seems that you should use the =
(equality) operator instead of @>
(containment).
It will filter only the exact rows and you could use them in a delta statment.
-
i have try this and works : select * from topdog where tags = '"created_by"=>"JOSM"' thanksjack– jack2016年09月01日 20:33:59 +00:00Commented Sep 1, 2016 at 20:33
use
select * from <table> where tags->'created_by' = 'JOSM' and len(akeys("tags"))=1
That way you select those that have the created_by tag and only one hstore key.
I don't know if len() is the correct function to use for "array element count" (maybe it's array_length()).
See the hstore doc at https://www.postgresql.org/docs/9.1/static/hstore.html .
(Disclaimer: I dont have a hstore enabled db to test with)
You should not remove the created_by tag on objects you are not otherwise modifying. If we wanted to remove them in bulk we'd do it some other way.