我在MySQL Workbench中编写了以下SQL查询:
SELECT
t1.sample_id, t1.v_id, t1.s_type as type, t1.s_fusion, t1.e_fusion, CONCAT(t1.cpt1, ":", t1.ppt1) as point1,
CONCAT(t1.cpt2, ":", t1.ppt2) as point2, t1.s_gene, t1.e_gene, t1.pscore as score, t2.manual_notes
FROM
(
s_samples
WHERE sample_id = 'S0001'
) as t1
INNER JOIN
(
SELECT c.v_id, c.sample_id,
CONCAT(c.sample_id,"(",e.disease,"): ",c.notes) as manual_notes
FROM all_samples e
LEFT JOIN s_samples c
ON e.sample_id=c.sample_id
WHERE c.notes is not null AND c.v_id IN
(SELECT v_id FROM s_samples)
AND c.sample_id = 'S0001'
) as t2
ON t1.v_id = t2.v_id
ORDER BY t1.v_id;
但是,我收到以下错误:“select”在此服务器版本的此位置无效,应为:“(”,有错误。我对SQL相对较新,所以不确定为什么会收到此错误以及如何解决此错误。请提供任何见解。
这不是有效的SQL:
FROM
(
s_samples
WHERE sample_id = 'S0001'
) as t1
也许你打算:
FROM (SELECT s.*
FROM s_samples s
WHERE s.sample_id = 'S0001'
) t1
当然,这是多余的。您可以只使用该表并将筛选放在外部的where
子句中。
我认为您的错误只是由于一些一般性的混淆造成的,因为编译器是混淆的。