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

Forzare tutte le righe dalla prima tabella di un join

SELECT p.*
     , SUM(mp.quantity) AS qty
FROM products p
  LEFT JOIN machine_products mp
    ON mp.product_id = p.product_id
    AND mp.machine_id = m              --- this condition moved from WHERE to ON
WHERE p.category_id = c
GROUP BY p.product_id