Mysql
 sql >> Datenbank >  >> RDS >> Mysql

SQL/PHP:Die 3 meistverkauften Produkte aus der Datenbank anzeigen

Versuchen Sie Folgendes:

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