feat: refs #8057 Added geoFk columns #3204
|
@ -14,9 +14,10 @@ BEGIN
|
||||||
SELECT p.geoFk INTO vGeoFk
|
SELECT p.geoFk INTO vGeoFk
|
||||||
FROM address a
|
FROM address a
|
||||||
JOIN town t ON t.provinceFk = a.provinceFk
|
JOIN town t ON t.provinceFk = a.provinceFk
|
||||||
JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode
|
JOIN postCode p ON p.townFk = t.id
|
||||||
WHERE a.id = vSelf
|
WHERE a.id = vSelf
|
||||||
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC
|
ORDER BY (a.city SOUNDS LIKE t.name) DESC,
|
||||||
|
(p.code = a.postalCode) DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
RETURN vGeoFk;
|
RETURN vGeoFk;
|
||||||
|
|
|
@ -15,9 +15,9 @@ BEGIN
|
||||||
FROM client c
|
FROM client c
|
||||||
JOIN town t ON t.provinceFk = c.provinceFk
|
JOIN town t ON t.provinceFk = c.provinceFk
|
||||||
JOIN postCode p ON p.townFk = t.id
|
JOIN postCode p ON p.townFk = t.id
|
||||||
AND p.`code` = c.postcode
|
|
||||||
WHERE c.id = vSelf
|
WHERE c.id = vSelf
|
||||||
ORDER BY (c.city SOUNDS LIKE t.`name`) DESC
|
ORDER BY (c.city SOUNDS LIKE t.name) DESC,
|
||||||
|
(p.code = c.postcode) DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
RETURN vGeoFk;
|
RETURN vGeoFk;
|
||||||
|
|
|
@ -15,9 +15,11 @@ BEGIN
|
||||||
FROM supplier s
|
FROM supplier s
|
||||||
JOIN town t ON t.provinceFk = s.provinceFk
|
JOIN town t ON t.provinceFk = s.provinceFk
|
||||||
JOIN postCode p ON p.townFk = t.id
|
JOIN postCode p ON p.townFk = t.id
|
||||||
AND p.`code` = s.postCode
|
LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
|
||||||
WHERE s.id = vSelf
|
WHERE s.id = vSelf
|
||||||
ORDER BY (s.city SOUNDS LIKE t.`name`) DESC
|
ORDER BY (s.city SOUNDS LIKE t.name) DESC,
|
||||||
|
(p.code = s.postCode) DESC,
|
||||||
|
(p.code = sad.postalCode) DESC
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
RETURN vGeoFk;
|
RETURN vGeoFk;
|
||||||
|
|
Loading…
Reference in New Issue