Hello everyone, there is a table:

CREATE TABLE `products` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(35) not null, `price` decimal(15, 2) not null, `category` JSON, PRIMARY KEY (`id`) ); INSERT INTO products VALUES( null, "Двигатель", '{"Категория": ["Самолёт", "Автомобиль", "Вертолёт"]}', 150 ); INSERT INTO products VALUES( null, "Инструменты", '{"Категория": ["Для приготовления пищи", "Для самолетостроения", "Для судностроения"]}', 150 ); 

But how to make an insert request, you need to add the product to the category with the price? I am completely confused with this syntax, but it looks easy.

    1 answer 1

     INSERT INTO products(name, price, category) VALUES( "Инструменты", '{"Категория": ["Для приготовления пищи", "Для самолетостроения", "Для судностроения"]}', 150 ); 
    • but the price is 150 for all three categories. or how? - Kryshtop
    • You have categories in the JSON string. It turns out, yes. Otherwise, the task is incomprehensible, formulate differently - Vyacheslav Potseluyko