这是查询1:
SELECT distinct c.chem_gene, m.String_name, m.ScopeNote
FROM mesher m INNER JOIN chem_base c
ON (c.chem_name = m.String_name AND m.ScopeNote <> '' )
where match (c.chem_gene) against('ACTN3, MTHFR' in boolean mode)
group by c.chem_gene, c.chem_name;
输出3行,如下所示:
'ACTN3', 'Estradiol', 'The 17-beta-isomer of estradiol...'
这是查询2(从第2列输出,“雌二醇”):
SELECT String10 FROM mesher where String_name = "Estradiol" AND String10 <>'' LIMIT 1;
在单列中输出单行:
'Estrogens'
如何修改查询1,以便对于返回的每一行,对第二列中的结果(即“'雌二醇”)进行附加查询以产生此输出:
'ACTN3', 'Estradiol', 'The 17-beta-isomer of estradiol...', 'Estrogens'
答案 0 :(得分:1)
如果我理解正确,您可以使用相关子查询:
SELECT c.chem_gene, m.String_name, m.ScopeNote,
(SELECT mm.String10
FROM mesher mm
WHERE mm.String_name = m.String_name AND mm.String10 <> ''
LIMIT 1
)
FROM mesher m INNER JOIN
chem_base c
ON c.chem_name = m.String_name AND m.ScopeNote <> ''
WHERE match(c.chem_gene) against( 'ACTN3, MTHFR' in boolean mode)
GROUP BY c.chem_gene, c.chem_name, m.ScopeNote ;
select distinct
不是必需的。