Unknown column 'img' in 'where clause': SELECT * FROM propiedades_imagenes WHERE tipo_imagen_fk <> 1 and tipo_imagen_fk <> 2 and propiedad_fk = img ORDER BY orden ASC