枢轴信息架构数据-MySQL

时间:2019-11-25 12:30:41

标签: mysql pivot

我正在使用以下脚本从information_schema.columns中提取数据

SELECT table_name,
   column_name
FROM information_schema.columns  
WHERE TABLE_NAME = 'member'
OR TABLE_NAME = 'site'
AND TABLE_SCHEMA = 'project'
ORDER BY TABLE_NAME

示例数据如下:


|table_name| column_name  |
|----------|--------------|
|site      |  site_id     |
|site      |   name       |
|member    |   mid        |
|member    |   name       |
|member    |   phone1     |
|member    |   phone2     |
|member    |   sex        |
|member    |   dob        |
|member    |   age_yrs    |
--------------------------

数据透视如下:


|site         |  member   |
---------------------------
|site_id      |  mid      |
|name         |  name     |
|             |  phone1   |
|             |  phone2   |
|             |  sex      |
|             |  dob      |
|             |  age_yrs  |
---------------------------

0 个答案:

没有答案