Skip to content

Instantly share code, notes, and snippets.

@spetrunia
Created May 9, 2020 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spetrunia/a905d51731c58f5439bd9f70c64cdc43 to your computer and use it in GitHub Desktop.
Save spetrunia/a905d51731c58f5439bd9f70c64cdc43 to your computer and use it in GitHub Desktop.
create table t2 (
color varchar(32),
price int
);
insert into t2 values ("red", 100), ("blue", 50);
insert into t2 select * from t2;
insert into t2 select * from t2;
set optimizer_switch='firstmatch=off';
explain
select *
from
json_table('[{"color": "blue", "price": 50},
{"color": "red", "price": 100}]',
'$[*]' columns( color varchar(100) path '$.color',
price text path '$.price'
)
) as T
where
T.color in (select color from t2 where t2.price=T.price);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment