Mysql
 sql >> Base de données >  >> RDS >> Mysql

SQL/PHP :Afficher les 3 produits les plus vendus à partir de la base de données

Essayez ceci :

$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";