[英]Grails sub query with createCriteria
我有如下的SQL查詢
select transf, count(fname) from peak_info where fname in (select peakfile from pe_result where conid = 'GO:0006007' and fdr > 0.05) group by transf;
我想在實現中創建標准。 當前,我先運行括號中的SQL查詢,然后運行如下外部查詢:
def test2 = PeResult.createCriteria() def ptest=test2.list { eq("conid",conid.toString()) gt("fdr","0.05") } def peaknames = ptest.peakfile def peakinfoFilter = PeakInfo.createCriteria() def pifilter = peakinfoFilter.list { 'in'("fname", peaknames) projections { groupProperty "transF" count "fname" } }
我想知道是否還有其他方法可以執行一個查詢而不是運行兩個查詢?
您可能可以做這樣的事情。 尚未執行,但您知道了。 看看GORM的子查詢部分。
def peakinfoFilter = PeakInfo.createCriteria()
def pifilter = peakinfoFilter.list {
'in' "fname", PeResult.where{
conid == conid.toString()
fdr > "0.05"
}. peakfile
projections
{
groupProperty "transF"
count "fname"
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.