MariaDB [object]> select Protein, count(mirna) from exp2
INTERSECT select Protein, count(mirna) from exp3 group by Protein;
错误1064(42000):您的SQL语法有错误;检查 与您的MariaDB服务器版本对应的手册 语法使用'select Protein,count(mirna)来自exp3 group by 蛋白质'在第1行。
我有两个表exp2和exp3,两个都有很多公共行,我想从这两个表的公共数据中查询。我想要一个共同的蛋白质数据表和数量相应的miRNA数量。
我正在使用lampp,如何解决此查询?
答案 0 :(得分:1)
MySQL不提供INTERSECT
操作。您需要使用类似JOIN操作的东西。此示例禁止所有与ON
条件不匹配的行。
SELECT a.Protein, a.mirnacount
FROM (SELECT Protein, count(mirna) mirnacount from exp2 group by Protein) a
JOIN (SELECT Protein, count(mirna) mirnacount from exp3 group by Protein) b
ON a.Protein = b.Protein AND a.mirnacount = b.mirnacount
如果您的项目需要完整的设置操作,您可以考虑切换到PostgreSQL。
答案 1 :(得分:0)
SELECT T1.Protein,count(T1.miRNAID)
FROM exp2 AS T1
INNER JOIN exp3 AS T2
ON T1.Protein = T2.Protein
AND T1.Target_Protein_id= T2.Target_Protein_id
AND T1.miRNAID=T2.miRNAID
GROUP BY T1.Protein
ORDER BY count(T1.miRNAID)
这对我来说非常适合。