I am running a MySQL query in Go. I want access the second row of the query result. I know I can use
for rows.Next {
}
But I don't want to run a loop for accessing the second row (and then breaking the loop after it iterates the second time). What to do?
Here is a code snippet:
rows,err:= db.Query("SELECT status,ts FROM events WHERE node = ? order by ts desc limit 2", testNode.ID);
defer rows.Close()
if ( err!= nil){
t.Error("Some Error" + err.Error())
}
isNext:=rows.Next()
if(isNext == false) {
t.Error(" No rows in query result")
}
rows.Scan(&status)
// What to do to use second row ?