This may be simpler to explain with an example. Consider the following simple json:
[ {"id": 1, "ref":32, "key":10}, {"id": 2, "ref":32, "key":75}, {"id": 3, "ref":27, "key":13}, {"id": 4, "ref":27, "key":42}, {"id": 5, "ref":438, "key":42}]I want to select using jq all elements that have a ref such that there is an element with that ref and key equal to 42.
select * from table where ref in (select ref from table where key = 42)I am totally stumped. I have managed to get the array of such ref '[.[]|select(.key==42).ref]'
I am even unclear how to select elements with .ref in a hard-coded list, e.g.
this returns elements that have ref == 32: .[] | select(.ref == 32)
But I do not know how to select records that have ref in the list [32,45].