From 747efc4342ac8da8994c8ac096f50f48cf655a0e Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 12 Apr 2023 14:52:59 +0200 Subject: [PATCH] refs #5540 sql mod --- db/changes/231401/00-updateIsVies.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/db/changes/231401/00-updateIsVies.sql b/db/changes/231401/00-updateIsVies.sql index efe008101..1d2e55441 100644 --- a/db/changes/231401/00-updateIsVies.sql +++ b/db/changes/231401/00-updateIsVies.sql @@ -1,5 +1,3 @@ -UPDATE vn.supplier s - JOIN vn.country c ON c.id = s.countryFk - SET s.nif = MID(REPLACE(s.nif, ' ', ''), 3, LENGTH(REPLACE(s.nif, ' ', '')) - 1) - WHERE s.isVies = TRUE - AND c.code = LEFT(REPLACE(s.nif, ' ', ''), 2); \ No newline at end of file +UPDATE vn.supplier +SET nif = SUBSTRING(nif, IF(ASCII(SUBSTRING(nif, 1, 1)) BETWEEN 65 AND 90 AND ASCII(SUBSTRING(nif, 2, 1)) BETWEEN 65 AND 90, 3, 1), LENGTH(nif)) +WHERE isVies = 1 AND nif REGEXP '^[a-zA-Z]{2}';