Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

SQL/PHP:Mostrar os 3 produtos mais vendidos do banco de dados


Tente isto:
$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";