Timetable
Column '_UOS_lookup' in where clause is ambiguous
SELECT
tt.Day, CONCAT(u.UOS_alpha, u.UOS_digit) AS UOS_Code,
tt.Hour_Begins,
tt.Hour_Duration,
tt.timetableID,
tt.Type,
(tt.Hour_Begins + tt.Hour_Duration) as Ends,
tt.Frequency,
tt.Start_Date,
tt.End_Date,
IF(
u.UOS_digit<5000,
IF(
ISNULL(URL.Undergraduate_UOS),
CONCAT("https://ssa.usyd.edu.au/ssa/handbook/uosdetail.jsp?uosindex=", u.UOS_index),
CONCAT(URL.Undergraduate_UOS, "?u=", u._UOS_lookup)
),
IF(
ISNULL(URL.Postgraduate_UOS),
CONCAT("https://ssa.usyd.edu.au/ssa/handbook/uosdetail.jsp?uosindex=", u.UOS_index),
CONCAT(URL.Postgraduate_UOS, "?u=", u._UOS_lookup)
)
) AS UOS_Link,
u.UOS_Name
FROM
timetable tt
LEFT JOIN UOS u ON tt._UOS_lookup=u._UOS_lookup
LEFT JOIN URL ON URL.departmentID=u.departmentID
WHERE
tt.Type NOT REGEXP "(Tutorial|Revision|Workshop|Lab)" AND
((tt.Frequency!='Once Only') OR (tt.Frequency='Once Only' AND End_Date>=CURRENT_DATE)) AND
u.departmentID REGEXP "^(68)$" AND
u.Academic_year=2013 AND u.sessionID REGEXP "^(1|6|7|8|31|61|63|64|65|101|102|103|104|105|106)$" AND
u.UOS_digit>=5000 AND _UOS_lookup NOT REGEXP "^(MUSM_7032_2012_101|MUSM_7027_2012_1|MUSM_7029_2012_106|MUSM_7031_2012_102|MUSM_7035_2012_104|MUSM_7033_2012_108|MUSM_7036_2012_112|MUSM_7030_2012_110)$"
ORDER BY
tt.Day, CONCAT(u.UOS_alpha, u.UOS_digit),
tt.Hour_Begins,
tt.Start_Date