Unknown column 'tipo' in 'where clause'