You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND (rs.SUB_ID IS NULL OR rs.SUB_ID = '') and active = 'Y' ORDER BY rs.ORD ASC' at line 1 QUERY:SELECT rs.* FROM resources rs WHERE rs.INDEX_KEY= AND (rs.SUB_ID IS NULL OR rs.SUB_ID = '') and active = 'Y' ORDER BY rs.ORD ASC