如何在grails中获取结果集数据

时间:2013-04-06 04:37:25

标签: java grails resultset

以下是我的询问:

def getdata1 = sql.rows("select student_id,school_grade_class_id from class_assign")

如何从student_id获取getdata1

更新

def getdata1 = sql.rows("select student_id,school_grade_class_id from class_assign")


def getdata2 = sql.rows("select class_id,class_name,school_grade_id from class_rel where school_grade_class_id=**x**")

我应该从alue of school_grade_class_id将x替换为结果集v getdata1。 我该怎么办?

1 个答案:

答案 0 :(得分:2)

您可以这样做:

getdata1.each{
    println it.student_id
}

或者

sql.eachRow("select student_id,school_grade_class_id from class_assign", {
   println it.student_id
})