0

Tbl1

id eez
1 8438
8493

Tbl2

eez_id name
8438 Greenlandic Exclusive Economic Zone
8493 Canadian Exclusive Economic Zone

Desired output

id eez name
1 8438 Greenlandic Exclusive Economic Zone
8493 Canadian Exclusive Economic Zone

So far I've done the below, but it is giving me undesired results. Any thoughts here?

select a.*, b.name
from tbl1 as a
left join tbl2 as b
on b.eez_id in unnest(a.eez);

1 Answer 1

1

Consider below approach

select id, 
  array(
    select as struct eez_id as eez, name
    from t1.eez eez_id
    join tbl2 
    using(eez_id)
  ) eezs
from tbl1 t1          

if applied to sample data in your question - output is

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.