EN
MySQL - Insert JSON type value to the table
0
points
In this article, we would like to show you how to insert JSON
type value to the table in MySQL.
Quick solution:
INSERT INTO `table_name` (`column_name`)
VALUES
('{"key1": value1, "key2": value2, "key3": value3}'),
('{"key4": value4, "key5": value5, "keyN": valueN}');
Practical example
To show how to insert JSON
type values to the table, we will use the objects
table created in the previous article:
Example
In this example, we will insert into the objects
table three new JSON
values.
Query:
INSERT INTO `objects` (`json`)
VALUES
('{"height": 100, "width": 100, "color": "red"}'),
('{"height": 200, "width": 200, "color": "green"}'),
('{"height": 300, "width": 300, "color": "blue"}');
Result: