
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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)
Advertisements