I'm running the query below and it is working well.
SELECT
stock_parts.title,
COUNT(*) as qtyAvailable,
SUM(shipments.item_cost) as totalValue,
### stock_alerts.minimum
FROM
stock_items
INNER JOIN stock_parts ON stock_items.stock_part_id = stock_parts.id
INNER JOIN shipments ON shipments.id = stock_items.shipment_id
### INNER JOIN stock_alerts ON stock_alerts.stock_part_id = stock_items.stock_part_id
WHERE
stock_items.status IS NULL
AND stock_items.current_stock_id = 1
GROUP BY stock_parts.id
So if I uncomment the two commented lines (is a join to get info from another table), the query results are filtered showing only rows where stock_alerts.minimum
is not null.
Why is this happening? I need all results event that column is NULL.