简体   繁体   中英

How to get resultset data in grails

Below is my query:

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

How do I get student_id from getdata1 ?

UPDATE:

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**")

I should replace x to resultset v alue of school_grade_class_id from getdata1 . What should i do?

You can do something like this:

getdata1.each{
    println it.student_id
}

Or

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM