我在 mysql 而不是 excel 中收集一些信息。为每种细胞类型定义了一些标签,并非所有标签都存在。所以,我有 3 个标签、信息和单元格表。
select cell_name, label, information from onco_celldb_information as info
left join onco_celldb_cells as cell on cell.`celldb_cell_id` = info.`celldb_cell_id`
left join onco_celldb_labels as label on info.`celldb_label_id` = label.`celldb_label_id`
order by cell.celldb_cell_id asc;
结果是:
但是我想要的是有这样的东西:
CellName Species CellType Origin
---------+-----------+-----------+-----------
P-815 Murine Mastroxxxx Human
L292 Something Megatrone Mouse
所以让它们按单元名称分组,并将结果作为列。如果标签不存在,则只有 NULL (某些结果可能不存在标签)。
你有什么建议?
用数据库结构编辑:
mysql> describe celldb_cells;
+----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------+------+-----+---------+----------------+
| celldb_cell_id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| cell_name | varchar(256) | YES | | NULL | |
+----------------+------------------+------+-----+---------+----------------+
describe celldb_information;
+-----------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+------------------+------+-----+---------+----------------+
| celldb_information_id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| celldb_cell_id | int(11) unsigned | YES | MUL | NULL | |
| celldb_label_id | int(11) unsigned | NO | MUL | NULL | |
| information | text | YES | | NULL | |
+-----------------------+------------------+------+-----+---------+----------------+
describe celldb_labels;
+-----------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+----------------+
| celldb_label_id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| label | varchar(256) | YES | | NULL | |
+-----------------+------------------+------+-----+---------+----------------+