我喜欢这样的mysql语句
SELECT distinct mk.gene as gene, qs.rs as snp, CONCAT (qs.A1, qs.A2) as genotype
FROM dallas.QS_base qs cross join
dallas.staging mk
ON qs.rs = mk.rs
WHERE qs.sampleID = 'mydna'
order by gene ASC;
返回这种类型的输出
'ACE' 'RS4343', 'AA'
'ACTN3' 'RS1815739' 'TC'
从这种类型的表(dallas.staging)
'heart health', 'ACE', 'RS4343'
'skin health', 'ACE', 'RS4343'
'sports performance', 'ACE', 'RS4343'
'sports performance', 'ACTN3', 'RS1815739'
'longevity', 'ACTN3', 'RS1815739'
还有这个(达拉斯QSU基地)
'mydna','RS4343','A','A'
'mydna','RS1815739','T','C'
我应该如何更改上面的mysql语句来获得这个输出?我想我需要使用组\u concat命令。
'ACE' 'RS4343', 'AA' '(heart health, sports performance, skin health)'
'ACTN3' 'RS1815739' 'TC' '(sports performance, longevity)'
1条答案
按热度按时间z18hc3ub1#
此查询应该为您完成这项工作(请注意,mk.gene上的distinct是不必要的,因为您正在按它进行分组):
输出: