salix/db/versions/.archive/10267-blueDracena/01-fixMerge.sql

12 lines
363 B
MySQL
Raw Normal View History

use vn;
DROP TEMPORARY TABLE IF EXISTS tWorkerLabour ;
CREATE TEMPORARY TABLE tWorkerLabour
SELECT l.workerFk, l.businessFk
FROM vn.workerLabour l
WHERE util.CURDATE() BETWEEN l.started AND IFNULL(l.ended, util.CURDATE());
UPDATE vn.worker w
JOIN tWorkerLabour l ON l.workerFk = w.id
SET w.businessFk = l.businessFk;
DROP TEMPORARY TABLE tWorkerLabour;