SQLSTATE[42804]: Datatype mismatch: 7 ERROR: argument of AND must be type boolean, not type integer LINE 1: ...contest_details c2 ON c.id = c2.contest_id WHERE (c.id AND... ^