I am trying to select records based on the order of array elements of another row:
SELECT * 
  FROM tester
  WHERE id IN (
    SELECT jsonb_array_elements(d->'fam')->>'id' 
    FROM tester
    WHERE id='3'
  ) 
I am aware of this solution.
The difference is that I don't know how to dynamically generate the "ordering" value. Is that possible?
The full fiddle is here.
I would like to see results based on the order found in the json data:
id  name    d
--  -----   --------
2   barb    {"fam": [{"id": 1}, {"id": 3}]}
4   jaimie  {"fam": [{"id": 3}, {"id": 2}, {"id": 1}]}
1   bob     {"fam": [{"id": 3}, {"id": 2}, {"id": 4}]}
