Извлечение ID
из JSON с использованием get_json_object()
и соединение с таблицей поиска, добавление фильтрации.
Демо-версия:
select s.cust_name, s.Address, s.ID, lkp.level
from
(select
get_json_object(json_col,'$.Info.ID') as ID,
get_json_object(json_col,'$.Name') as cust_name,
get_json_object(json_col,'$.Info.Address') as Address
from
( --replace this subquery with your table
select '{"Name": "John Doe","Info" : {"Address": "111 Main Street","ID": 2222}}' as json_col)s
) s
left join
( --replace this subquery with your table
select stack(4,
1111, 1,
1123, 4,
2234, 1,
2222, 3
) as (ID, Level)
)lkp on s.ID=lkp.ID
where lkp.Level !=1 --filter out level 1
or lkp.level is null --this is to allow records without corresponding level in lkp
;
Результат:
OK
cust_name address id level
John Doe 111 Main Street 2222 3
Time taken: 31.469 seconds, Fetched: 1 row(s)