Error description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND lp.categoria_id = 31 group by p.id ORDER BY pp.posicion asc' at line 1
SELECT pd.id, pd.nombre, p.id, MIN(if(pd.descuento > 0, pd.descuento, pd.precio)) as valorMenor, pd.stock, pd.stock_reserva, p.marca_id FROM productos p JOIN productos_detalles pd ON p.id = pd.producto_id LEFT JOIN posicion_productos_categoria pp ON p.id = pp.producto_id LEFT JOIN lineas_productos lp ON p.id = lp.producto_id WHERE p.publicado = 1 AND lp.linea_id = AND lp.categoria_id = 31 group by p.id ORDER BY pp.posicion asc