mirror of
https://github.com/grocy/grocy.git
synced 2026-04-06 04:46:16 +02:00
12 lines
353 B
SQL
12 lines
353 B
SQL
DROP VIEW stock_current_locations;
|
|
CREATE VIEW stock_current_locations AS
|
|
SELECT
|
|
s.id,
|
|
s.product_id,
|
|
IFNULL(s.location_id, p.location_id) AS location_id,
|
|
l.name AS name
|
|
FROM stock s
|
|
JOIN products p ON s.product_id = p.id
|
|
JOIN locations l on IFNULL(s.location_id, p.location_id) = l.id
|
|
GROUP BY s.product_id, IFNULL(s.location_id, p.location_id)
|