gpt4 book ai didi

sql - 使用createCriteria进行Grails子查询

转载 作者:行者123 更新时间:2023-12-02 14:48:24 25 4
gpt4 key购买 nike

我有如下的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;


我想在grails中实施创建标准。当前,我先运行括号中的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"
}
}

关于sql - 使用createCriteria进行Grails子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54261282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com