Skip to content
Advertisement

check if row exists with specific value

I have 2 tables task and taskattributes. There is a linking between 2 tables with taskid. Each taskid has multiple attributes represented by key,value. I would like to find out if specific key exists for the task

enter image description here

enter image description here

For e.g. here if I want to check all the tasks which do not have key ‘A’.

Advertisement

Answer

One simple solution uses aggregation:

If you are using Postgres 9.4 or later, you may use FILTER in the HAVING clause:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement