Invalid query SELECT w.* FROM w, p_w, p WHERE p_w.p= AND w.id=p_w.w AND p.pub='checked' GROUP BY w.id ORDER BY tit ASC: 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 w.id=p_w.w AND p.pub='checked' GROUP BY w.id ORDER BY tit ASC' at line 1