
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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 Articles
- Pull and add to set at the same time with MongoDB? Is it Possible?
- Is it possible to use UPDATE query with LIMIT in MySQL?
- Is it possible to override a Java method of one class in same?
- Is it possible to calculate a correlation in a MySQL query?
- Is it possible to add HTML5 validation to Visual Studio?
- Add elements to a Set using Javascript
- Is it possible to have a function-based index in MySQL?
- How is it possible to filter out the duplications in the rows of result set return by MySQL?
- Insert the results of a MySQL select? Is it possible?
- How to add one or more header cells a cell is related to in HTML?
- How to add time in a MySQL column set with type DATETIME?
- Check if is possible to get given sum from a given set of elements in Python
- Is it possible to have View and table with the same name in MySQL?
- How can it be possible to add 3 months interval in a MySQL date without using the word ‘Months’ with interval?
- Possible number of Rectangle and Squares with the given set of elements in C++

Advertisements