7806_devToTest_2332 #2801
|
@ -1,8 +1,21 @@
|
||||||
ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL;
|
ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tBuyers
|
||||||
|
ENGINE = MEMORY
|
||||||
|
WITH tDistinctBuyers AS (
|
||||||
|
SELECT DISTINCT buyer
|
||||||
|
FROM bs.waste w
|
||||||
|
)
|
||||||
|
SELECT buyer, u.id
|
||||||
|
FROM tDistinctBuyers tdb
|
||||||
|
JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci
|
||||||
|
|
||||||
|
|
||||||
UPDATE bs.waste w
|
UPDATE bs.waste w
|
||||||
JOIN account.`user` u ON u.name = w.buyer COLLATE utf8mb3_unicode_ci
|
JOIN tBuyers tb ON tb.buyer = w.buyer
|
||||||
SET w.buyerFk = u.id;
|
SET w.buyerFk = tb.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tBuyers;
|
||||||
|
|
||||||
ALTER TABLE bs.waste
|
ALTER TABLE bs.waste
|
||||||
DROP PRIMARY KEY,
|
DROP PRIMARY KEY,
|
||||||
|
|
Loading…
Reference in New Issue