

- 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
Is it possible to add a set of elements in one cell with MySQL?
To add a set of elements in a single cell, use the concept of JSON. Let us first create a table −
mysql> create table DemoTable1828 ( EmployeeId int, EmployeeRecords JSON ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1828 values(1,'[{"EmployeeName":"Chris","EmployeeAge":29},{"EmployeeName":"David","EmployeeAge":27}]'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1828 values(2,'[{"EmployeeName":"John","EmployeeAge":36},{"EmployeeName":"Mike","EmployeeAge":32}]'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1828;
This will produce the following output −
+------------+----------------------------------------------------------------------------------------------+ | EmployeeId | EmployeeRecords | +------------+----------------------------------------------------------------------------------------------+ | 1 | [{"EmployeeAge": 29, "EmployeeName": "Chris"}, {"EmployeeAge": 27, "EmployeeName": "David"}] | | 2 | [{"EmployeeAge": 36, "EmployeeName": "John"}, {"EmployeeAge": 32, "EmployeeName": "Mike"}] | +------------+----------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- Pull and add to set at the same time with MongoDB? Is it Possible?
- Is it possible to override a Java method of one class in same?
- Is it possible to use UPDATE query with LIMIT in MySQL?
- Insert the results of a MySQL select? Is it possible?
- Is it possible to add HTML5 validation to Visual Studio?
- How to add one or more header cells a cell is related to in HTML?
- Is it possible to calculate a correlation in a MySQL query?
- Is it possible to have a function-based index in MySQL?
- Is it possible to have multiple try blocks with only one catch block in java?
- Check if it is possible to transform one string to another in Python
- Add elements to a Set using Javascript
- Is it possible to manually set the attribute value of a Web Element using Selenium?
- Check if it is possible to convert one string into another with given constraints in Python
- Change One Cell's Data in MySQL?
- How is it possible to filter out the duplications in the rows of result set return by MySQL?
Advertisements