MDB2 Error: syntax error; _doQuery: [Error message: Could not execute statement] [Last executed query: SELECT SQL_CALC_FOUND_ROWS Item.*, IF(Item.Date, date_format(Item.Date,'%c/%e/%Y'), '') as updated_fmt, band_id, band_name, IF(band_private = 'yes','', band_url) as band_url, IF(band_private = 'yes','', band_image_name) AS band_image_name, band_url, fno_event_band_id, IF(fno_event_image_size AND quota_photos = 'yes' AND quota_image_max > 0 AND ( SELECT COUNT(fno_event_id) AS count FROM jamroom_fno_events m_max WHERE m_max.fno_event_band_id = b.band_id and m_max.fno_event_image_size AND m_max.fno_event_id <= i.fno_event_id ) <= quota_image_max , fno_event_image_size, 0) AS fno_event_image_size, ifnull( floor((to_days(CURDATE()) - 1 - to_days(STR_TO_DATE(concat(E_date_yr,'-',if(E_date_mo='tba',12,E_date_mo),'-',if(E_date_dy='tba',31,E_date_dy)), '%Y-%m-%d'))) / 365) + 1, 0 ) as eventYearsPassed FROM Item LEFT JOIN jamroom_fno_events i ON (fno_event_id=Item.ID) LEFT JOIN jamroom_band_info b ON (Item.MemberID=band_id) LEFT JOIN jamroom_quota q ON q.quota_id = b.band_quota WHERE Status not in ('Postponed','Canceled') AND In_pro_search = 'yes' AND No_publish != 'yes' AND ( S_date_mo = '12' OR E_date_mo = '12' OR CASE WHEN period_DIFF(left(End_date,6),left(Start_date,6))>=12 THEN 1 WHEN YEAR(End_date) > YEAR(Start_date) THEN ('12' >= S_date_mo OR '12' <= E_date_mo) ELSE '12' between S_date_mo and E_date_mo END OR S_date_mo = '01' OR E_date_mo = '01' OR CASE WHEN period_DIFF(left(End_date,6),left(Start_date,6))>=12 THEN 1 WHEN YEAR(End_date) > YEAR(Start_date) THEN ('01' >= S_date_mo OR '01' <= E_date_mo) ELSE '01' between S_date_mo and E_date_mo END ) A ORDER BY S_date_mo < MONTH(CURDATE()) ASC, S_date_mo ASC, S_date_dy ASC, concat(S_date_mo,' ',S_date_dy,'-',E_date_mo,' ',E_date_dy,' ',E_date_yr) ASC LIMIT 0, 24 ] [Native code: 1064] [Native message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'A ORDER BY S_date_mo < MO...' at line 37]