Falló la consulta select * from detalles where id_subcategoria= AND referencia != '' AND activo = 1 ORDER BY id_detalle ASC