Mysql
 sql >> Database >  >> RDS >> Mysql

SQL/PHP:mostra i primi 3 prodotti più venduti dal database

Prova questo:

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