This commit is contained in:
parent
cdcc5051d2
commit
8d4769d74d
|
@ -15,6 +15,7 @@ BEGIN
|
||||||
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
|
JOIN postCode p ON p.townFk = t.id
|
||||||
|
AND (p.code = a.postalCode OR a.postalCode IS NULL)
|
||||||
JOIN zoneGeo zg ON zg.id = p.geoFk
|
JOIN zoneGeo zg ON zg.id = p.geoFk
|
||||||
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,
|
||||||
|
|
|
@ -15,6 +15,7 @@ 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 OR c.postcode IS NULL)
|
||||||
JOIN zoneGeo zg ON zg.id = p.geoFk
|
JOIN zoneGeo zg ON zg.id = p.geoFk
|
||||||
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,
|
||||||
|
|
|
@ -15,6 +15,7 @@ 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 OR s.postCode IS NULL)
|
||||||
LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
|
LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
|
||||||
JOIN zoneGeo zg ON zg.id = p.geoFk
|
JOIN zoneGeo zg ON zg.id = p.geoFk
|
||||||
WHERE s.id = vSelf
|
WHERE s.id = vSelf
|
||||||
|
|
|
@ -10,6 +10,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo
|
||||||
FROM vn.address a
|
FROM vn.address a
|
||||||
JOIN vn.town t ON t.provinceFk = a.provinceFk
|
JOIN vn.town t ON t.provinceFk = a.provinceFk
|
||||||
JOIN vn.postCode p ON p.townFk = t.id
|
JOIN vn.postCode p ON p.townFk = t.id
|
||||||
|
AND (p.code = a.postalCode OR a.postalCode IS NULL)
|
||||||
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
|
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
|
||||||
GROUP BY a.id
|
GROUP BY a.id
|
||||||
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC,
|
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC,
|
||||||
|
|
|
@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo
|
||||||
FROM vn.client c
|
FROM vn.client c
|
||||||
JOIN vn.town t ON t.provinceFk = c.provinceFk
|
JOIN vn.town t ON t.provinceFk = c.provinceFk
|
||||||
JOIN vn.postCode p ON p.townFk = t.id
|
JOIN vn.postCode p ON p.townFk = t.id
|
||||||
|
AND (p.code = c.postcode OR c.postcode IS NULL)
|
||||||
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
|
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
|
||||||
GROUP BY c.id
|
GROUP BY c.id
|
||||||
ORDER BY (c.city SOUNDS LIKE t.`name`) DESC,
|
ORDER BY (c.city SOUNDS LIKE t.`name`) DESC,
|
||||||
|
|
|
@ -12,6 +12,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo
|
||||||
FROM vn.supplier s
|
FROM vn.supplier s
|
||||||
JOIN vn.town t ON t.provinceFk = s.provinceFk
|
JOIN vn.town t ON t.provinceFk = s.provinceFk
|
||||||
JOIN vn.postCode p ON p.townFk = t.id
|
JOIN vn.postCode p ON p.townFk = t.id
|
||||||
|
AND (p.code = s.postCode OR s.postCode IS NULL)
|
||||||
LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id
|
LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id
|
||||||
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
|
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
|
||||||
GROUP BY s.id
|
GROUP BY s.id
|
||||||
|
|
Loading…
Reference in New Issue