프로그램 Running Man 의 채널 및 시즌 조회
select
id, // 13515
JSON_EXTRACT(program_json, "$.channel"), // SBS
JSON_EXTRACT(program_json, "$.season") // 1
from program_info
where program_name = "Running Man";
프로그램 You Quiz 중 season이 3인 데이터 조회
select
id, // 13514
JSON_EXTACT(program_json, "$.channel"), // tvN
JSON_EXTACT(program_json, "$.season") // 3
from program_info
where program_name = "You Quiz On The Block" and JSON_EXTRACT(program_json, "$.season") = 3
2. 데이터 OR 조건 조회 (JSON_OVERLAPS)
[유재석, 이수근] 이 출연한 프로그램 조회
select
id,
JSON_EXTRACT(program_json, "$.channel") as channel,
JSON_EXTRACT(program_json, "$.season") as season,
JSON_EXTRACT(program_json, "$.cast") as cast
from program_info
where JSON_OVERLAPS(program_json->"$.cast", CAST("['유재석', '이수근']"))
--------------------------------------------------
| i d | channel | season | cast
--------------------------------------------------
| 10824 | tvN | 1 | 유재석, 조세호, ...
| 10825 | JTBC | 1 | 강호동, 이수근, ...
| 13514 | tvN | 3 | 유재석, 이말년, ...
| 13515 | SBS | 1 | 유재석, 김종국, ...
3. 데이터 AND 조건 조회 (JSON_CONTAIN)
[유재석, 이수근] 이 출연한 프로그램 조회
select
id,
JSON_EXTRACT(program_json, "$.channel") as channel,
JSON_EXTRACT(program_json, "$.season") as season,
JSON_EXTRACT(program_json, "$.cast") as cast
from program_info
where JSON_OVERLAPS(program_json->"$.cast", CAST("['유재석', '이수근']"))
--------------------------------------------------
| i d | channel | season | cast
--------------------------------------------------
[유재석, 이말년] 이 출연한 프로그램 조회
select
id,
JSON_EXTRACT(program_json, "$.channel") as channel,
JSON_EXTRACT(program_json, "$.season") as season,
JSON_EXTRACT(program_json, "$.cast") as cast
from program_info
where JSON_OVERLAPS(program_json->"$.cast", CAST("['유재석', '이말년']"))
--------------------------------------------------
| i d | channel | season | cast
--------------------------------------------------
| 13514 | tvN | 3 | 유재석, 이말년, ...
댓글