15 lines
513 B
MySQL
15 lines
513 B
MySQL
|
ALTER TABLE `vn`.`entry` ADD observationEditorFk INT(10) unsigned NULL COMMENT 'Último usuario que ha modificado el campo evaNotes';
|
||
|
ALTER TABLE `vn`.`entry` ADD CONSTRAINT entry_observationEditorFk FOREIGN KEY (observationEditorFk) REFERENCES account.user(id) ON UPDATE CASCADE;
|
||
|
|
||
|
UPDATE
|
||
|
`vn`.`entry` e
|
||
|
SET
|
||
|
observationEditorFk = (
|
||
|
SELECT w.userFk
|
||
|
FROM
|
||
|
`vn`.`worker` w
|
||
|
JOIN `account`.`user` u ON
|
||
|
u.id = w.userFk
|
||
|
WHERE
|
||
|
w.code = RIGHT(e.evaNotes,3)),
|
||
|
evaNotes = LEFT(evaNotes,LENGTH(evaNotes)-5)
|