Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE foobar ( id bigint unsigned auto_increment, items json null, PRIMARY KEY (`id`) ); INSERT INTO foobar (items) VALUES ('[{"task_id": 11, "auto_task_id": 1}, {"task_id": 71, "auto_task_id": 3}]'); INSERT INTO foobar (items) VALUES ('[{"task_id": 21, "auto_task_id": 1}, {"task_id": 23, "auto_task_id": 64}]'); INSERT INTO foobar (items) VALUES ('[{"task_id": 31, "auto_task_id": 2}, {"task_id": 45, "auto_task_id": 16}]'); -- получить записи у которых НЕТ "auto_task_id": 1 select * , JSON_EXTRACT(items, '$[*].auto_task_id') from foobar where not json_contains(JSON_EXTRACT(items, '$[*].auto_task_id'), '1', '$');

Stuck with a problem? Got Error? Ask AI support!

Copy Clear