sql >> Base de Datos >  >> RDS >> Mysql

SQL/PHP:muestra los 3 productos más vendidos de la base de datos

Prueba esto:

$sql = "SELECT SUM(order_count.number) AS total, image.image_link AS image_link 
FROM product JOIN order_count 
ON product.product_id = order_count.product_id 
JOIN image ON product.image_id = image.image_id
GROUP BY order_count.product_id 
ORDER BY total DESC 
LIMIT 3";