0
我试图执行查询来收集特定数据,但在查询的on
部分查询中遇到问题。要开始了,这是我的课:HQL加入Grails
class TimeSlot {
String timeslot_id
String time_chunk_id
String uid
String exam_id
String start_time
String is_special_arrangement
static mapping = {
table 'timeslot'
id name: "timeslot_id", column: "timeslot_id"
version false
}
}
这是我试图让工作查询:
TimeSlot.executeQuery("Select t.time_chunk_id, t.uid, t.start_time, t.timeslot_id, t.is_special_arrangement, e.length from TimeSlot t inner join Exams e on t.exam_id = e.exam_id where t.exam_id = ? and t.time_chunk_id = ?", [testArray[i], timeChunkArray[x]])
它是在on
部分抛出一个错误,因为它期待一个条款,但我需要数据具体涉及两个表的exam.id
比较。有没有另外一种方法来解决这个问题,或者另一种方法来设置查询,这样它就可以像在任何SQL编辑器中一样工作?
使用'with',而不是在查询'on'会更容易些。 HQL不支持'on'关键字。它的等价物是'与'。 – dmahapatro
这会带走错误,但现在它说无法在't.exam_id = e.exam_id'解析符号't'。任何建议,为什么发生这种情况? – thehoule64
使用'从TimeSlot作为T,考试作为e其中t.exam_id = e.exam_id'。 – dmahapatro