SQL Query Error (SELECT i.*, u.first_name, u.last_name, u.phone, u.email, salt.name as salary_type_name, DATE_FORMAT(i.post_date,'%m/%d/%Y') as post_date, DATE_FORMAT(i.post_date,'%M %d, %Y') as create_date, cat.name as category_name, cat2.name as sub_category_name, oc.title as owner_criteria_title FROM (category_specifications cat, users u, items i ) left join category_specifications as cat2 on (i.ref_sub_category=cat2.id) left join salary_types as salt on (i.salary_type=salt.id) left join owner_criteria as oc on (i.owner_criteria=oc.id) WHERE u.id=i.ref_user and cat.id=i.ref_category AND AND i.ref_status = '1' ) : 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 'AND i.ref_status = '1'' at line 11