SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE `table_a` ( `id` int(11) NOT NULL, `references` json NULL ); CREATE TABLE `table_b` ( `id` int(11) NOT NULL, `name` text NULL ); INSERT INTO `table_a` (`id`, `references`) VALUES (1, '\"[1,3]\"'), (2, '\"[2,3]\"'); INSERT INTO `table_b` (`id`, `name`) VALUES (1, 'item_1'), (2, 'item_2'), (2, 'item_3'); SELECT * from table_a; SELECT * from table_b; select table_a.*, table_b.* from table_a join table_b on JSON_CONTAINS( CAST(TRIM('"' FROM `references`) as JSON), CAST(table_b.id as JSON) ) where table_a.id=2;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear