Home  >  Article  >  Database  >  mysql converts large amounts of data into arrays

mysql converts large amounts of data into arrays

王林
王林forward
2020-01-28 21:08:322540browse

mysql converts large amounts of data into arrays

Requirements analysis:

As shown in the picture:

mysql converts large amounts of data into arrays

In the excel file shown above, each The corresponding advertising space under the field is presented in the form of an array as shown below:

(Free learning video tutorial recommended: mysql video tutorial)

mysql converts large amounts of data into arrays

Solution:

1. First, use the mysql client Navicat for MySQL to import excel files in batches and create tables;

2. Then use the mysq function GROUP_CONCAT. The specific method is as follows :

select 'country' ,country,GROUP_CONCAT(placementid)
from 2019q2
group by country
 union all
select 'year' ,year,GROUP_CONCAT(placementid)
from 2019q2
group by year
 union all
select 'quarter' ,quarter,GROUP_CONCAT(placementid)
from 2019q2
group by quarter

Recommended related articles and tutorials: mysql tutorial

The above is the detailed content of mysql converts large amounts of data into arrays. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete