
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Insert JSON into a MySQL table?
Let us create a table and set a column value with type JSON
mysql> create table DemoTable1832 ( ListOfNames JSON ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1832(ListOfNames) values('["Sam", "Mike", "Carol"]'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1832(ListOfNames) values('["David", "Bob"]'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1832(ListOfNames) values('["Adam", "John","Sam"]'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1832;
This will produce the following output −
+--------------------------+ | ListOfNames | +--------------------------+ | ["Sam", "Mike", "Carol"] | | ["David", "Bob"] | | ["Adam", "John", "Sam"] | +--------------------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL INSERT INTO SELECT into a table with AUTO_INCREMENT
- How can we insert data into a MySQL table?
- Auto insert values into a MySQL table in a range?
- MySQL trigger to insert row into another table?
- How can we insert a new row into a MySQL table?
- Insert MAX(col)+1 into the same MySQL table?
- How to write MySQL procedure to insert data into a table?
- INSERT INTO table if a table exists in MySQL else implement CREATE TABLE and create the table
- MySQL query for INSERT INTO using values from another table?
- Split a string and insert it as individual values into a MySQL table?
- How to insert only a single column into a MySQL table with Java?
- MySQL statement to copy data from one table and insert into another table
- Entering JSON data into MySQL?
- How to insert/store JSON array into a database using JDBC?
- How to convert JSON string into Lua table?
Advertisements