Doesn't have to be the longest you can find.
This is one I am working with at the moment, the size varies depending on some parameters, but this is basically it.
It's for a tool that I am developing for a course at Uni.
It's supposed to help exam planers with their work.
This SQL-query in particular, is used to detect exam collisions.
Code: Select all
SELECT
Programs.ProgramName,
Courses.CourseCode,
Courses.CourseType
FROM Programs
INNER JOIN CPConnection ON ProgramID = CProgramID
INNER JOIN Courses ON CCourseID = CourseID
INNER JOIN Statuses ON Courses.StatusID = Statuses.StatusID
WHERE
(Courses.ExamDate = '2009-11-19'
OR Courses.ReExamDate1 = '2009-11-19'
OR Courses.ReExamDate2 = '2009-11-19')
AND NOT (Courses.ExamDate = '0000-00-00'
OR Courses.ReExamDate1 = '0000-00-00'
OR Courses.ReExamDate2 = '0000-00-00')
AND NOT Courses.CourseID = 50
AND (Statuses.StatusName = 'Bokad'
OR Statuses.StatusName = 'Planerad')
AND Programs.ProgramName = 'FriAPS';