【发布时间】:2013-02-16 00:46:18
【问题描述】:
所以我有这个非常丑陋(但功能强大)的多子查询 mysql Select 命令。
select myt_taxon_list, count(myt_taxon_list)
from (select t1.taxon_list as myt_taxon_list, t1.query_prot_id,
count(t1.query_prot_id) / (select count(t.id)
from taxa t, stax st
where t.systematics like concat('%; ', st.taxon_list, '%')
and t.taxon_name not like '%thaliana%'
and st.taxon_list = t1.taxon_list
group by t1.taxon_list) as taxfrac
from task1 t1
where t1.taxon_list = 'Stramenopiles'
group by t1.query_prot_id) myt
where taxfrac > 0.5
在最后一行中,您可以阅读“Stramenopiles”。其结果是一个简单的计数。现在我想编写一个 bash 脚本,该脚本不仅为 Stramenopiles 还为该列中的所有条目写入计数 - 不是总和,而是每个分隔的条目。我需要将它与 bash 中的迭代循环结合起来,但我以前从未编写过脚本。有人可以帮我解决这个问题吗?
【问题讨论】:
-
这似乎是两个问题合而为一。您需要先以某种方式提取列中的条目,然后才能编写循环来遍历它们(这是单独的问题)。你知道第一部分怎么做吗?
-
感谢您的澄清!不幸的是,我真的不知道该怎么做:(
-
SELECT DISTINCT taxon_list FROM task1呢? -
我必须放在哪里?你的意思是不是“t1.taxon_list = 'Stramenopiles'”?
标签: mysql bash loops select count