SELECT item_id, warehouse_id, SUM(amount) amount
FROM basket_item
GROUP BY warehouse_id
CREATE TEMPORARY TABLE tmp.bionic_calc
(INDEX (item_id))
ENGINE=MEMORY
SELECT Id_Article item_id FROM vn2008.Articles
WHERE #filter;
CALL bionic_calc ();
SELECT t.item_id, t.available, t.price, t.producer,
a.Foto, a.Article, a.Categoria, a.Medida, a.Tallos, a.Color, o.Abreviatura
FROM tmp.bionic_item t
JOIN vn2008.Articles a ON a.Id_Article = t.item_id
LEFT JOIN vn2008.Origen o ON a.id_origen = o.id
WHERE t.available > 0
ORDER BY a.Article, a.Medida
LIMIT 400;
CALL bionic_from_item (#item);
SELECT p.warehouse_id, p.grouping, p.price, p.rate,
t.amount, l.available - IFNULL(t.amount, 0) available
FROM tmp.bionic_lot l
JOIN tmp.bionic_price p
ON p.warehouse_id = l.warehouse_id
LEFT JOIN (
SELECT warehouse_id, SUM(amount) amount
FROM basket_item
WHERE item_id = #item
GROUP BY warehouse_id
) t
ON t.warehouse_id = l.warehouse_id
ORDER BY warehouse_id, grouping;
Catalog
SELECT id, reino, color FROM vn2008.reinos
WHERE display != FALSE ORDER BY reino
CALL type_list (#realm)