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 folder_id = f.id and f.account_id = a.id and a.status_id = 2 and v.account_i' at line 2