feat: refactor buyUltimate refs #7736
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Andrés 2024-07-19 15:34:32 +02:00
parent fe363fd4db
commit 5567359d73
1 changed files with 3 additions and 4 deletions

View File

@ -1,5 +1,5 @@
ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL;
USE vn;
CREATE OR REPLACE TEMPORARY TABLE tBuyers
ENGINE = MEMORY
WITH tDistinctBuyers AS (
@ -8,8 +8,7 @@ CREATE OR REPLACE TEMPORARY TABLE tBuyers
)
SELECT buyer, u.id
FROM tDistinctBuyers tdb
JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci
JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci;
UPDATE bs.waste w
JOIN tBuyers tb ON tb.buyer = w.buyer
@ -51,4 +50,4 @@ INSERT INTO bs.waste
ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk);
DROP TEMPORARY TABLE tBuyers, tWasteUnique;
DROP TEMPORARY TABLE tWasteUnique;