[postgis-users] How to use UPDATE command with LIKE clause?

KhunSanAung khunsanaung.gis at gmail.com
Wed Apr 29 01:36:32 PDT 2015


Hi All,

I've two tables with similar columns storing text values.
agriculture (name, code, geom)
town (name, code, geom)

I'd like to run the UPDATE geom column for a string columns.

UPDATE public.agriculture SET
geom = towns.geom
FROM towns
FOR EACH ROW
WHERE agriculture."code" LIKE towns."code";

​The problem here is the values of 'code' columns​ are not always exactly
the same.
agriculture.code sometimes contains additional text
So I've to use the LIKE command. e.g.
town.code = 'MMR013025'
agriculture.code = 'MMR013025*701*'

​in that case I also like to have the values from towns aslo.​

​​UPDATE public.agriculture SET
geom = towns.geom
FROM towns
FOR EACH ROW
WHERE agriculture."code" LIKE '*MMR013025*%'
​
What would be the right command ​to do it?

Thank you very much in advance.

-- 
Have a nice day!
--

*Mr. Khun San Aung*
* <http://geoportal.icimod.org/>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150429/20fdfba4/attachment.html>


More information about the postgis-users mailing list