SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "and" LINE 1: ...cd_deposito = a.cd_deposito where b.id_armazen = and a.stat... ^