I have a SQL query where I would like to select rows from lesson table where idLesson column is greater than MAX from idLesson of attendance table. How can I correct this query?
SELECT student.userid, lessons.idLesson, student.fee, lessons.datePassed
FROM student
Inner JOIN `project_course`.group ON group.idGroup = student.idGroup
Inner JOIN lessons ON group.idGroup=lessons.idGroup
Inner JOIN attendance ON lessons.idLesson>MAX(attendance.idLesson)
group by lessons.idlesson;
This is your query modified according to your explanation
where idLesson column is greater than MAX from idLesson of attendance table
SELECT student.userid, lessons.idLesson, student.fee, lessons.datePassed
FROM student
Inner JOIN `project_course`.group ON group.idGroup = student.idGroup
Inner JOIN lessons ON group.idGroup=lessons.idGroup
WHERE lessons.idLesson >
( SELECT MAX(attendance.idLesson)
FROM attendance
)
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.