<div dir="ltr"><div class="gmail_default" style="color:rgb(0,0,255)">Hi Hug,</div><div class="gmail_default" style="color:rgb(0,0,255)"><br></div><div class="gmail_default"><div class="gmail_default" style="color:rgb(0,0,255)">That is helpful for me. Correction to the above command is;</div><div class="gmail_default"><font face="monospace, monospace" color="#660000">UPDATE agriculture SET</font></div><div class="gmail_default"><font face="monospace, monospace" color="#660000"><span class="" style="white-space:pre">        </span>geom = towns.geom</font></div><div class="gmail_default"><font face="monospace, monospace" color="#660000">FROM towns </font></div><div class="gmail_default"><font face="monospace, monospace" color="#660000">WHERE agriculture."code" LIKE towns."code"||'%'; </font></div></div><div class="gmail_default" style="color:rgb(0,0,255)"><br></div><div class="gmail_default" style="color:rgb(0,0,255)">Many thanks again & best regards</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 29, 2015 at 5:42 PM, Hugues François <span dir="ltr"><<a href="mailto:hugues.francois@irstea.fr" target="_blank">hugues.francois@irstea.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
It sounds more like a sql question than a postgis one but I think concatenate should helps:<br>
<span class=""><br>
<br>
UPDATE public.agriculture SET<br>
        geom = towns.geom<br>
        FROM towns<br>
FOR EACH ROW<br>
</span>WHERE agriculture."code" LIKE towns."code"||'%';<br>
<br>
HTH<br>
<br>
Hug<br>
<br>
<br>
<br>
-------- Message original --------<br>
De : KhunSanAung <<a href="mailto:khunsanaung.gis@gmail.com">khunsanaung.gis@gmail.com</a>><br>
Envoyé : Wednesday, April 29, 2015 10:37 AM<br>
À : <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
Sujet : [postgis-users] How to use UPDATE command with LIKE clause?<br>
<span class=""><br>
Hi All,<br>
<br>
I've two tables with similar columns storing text values.<br>
agriculture (name, code, geom)<br>
town (name, code, geom)<br>
<br>
I'd like to run the UPDATE geom column for a string columns.<br>
<br>
UPDATE public.agriculture SET<br>
geom = towns.geom<br>
FROM towns<br>
FOR EACH ROW<br>
WHERE agriculture."code" LIKE towns."code";<br>
<br>
​The problem here is the values of 'code' columns​ are not always exactly<br>
the same.<br>
agriculture.code sometimes contains additional text<br>
So I've to use the LIKE command. e.g.<br>
town.code = 'MMR013025'<br>
</span>agriculture.code = 'MMR013025*701*'<br>
<span class=""><br>
​in that case I also like to have the values from towns aslo.​<br>
<br>
​​UPDATE public.agriculture SET<br>
geom = towns.geom<br>
FROM towns<br>
FOR EACH ROW<br>
</span>WHERE agriculture."code" LIKE '*MMR013025*%'<br>
<span class="">​<br>
What would be the right command ​to do it?<br>
<br>
Thank you very much in advance.<br>
<br>
--<br>
Have a nice day!<br>
--<br>
<br>
</span>*Mr. Khun San Aung*<br>
* <<a href="http://geoportal.icimod.org/" target="_blank">http://geoportal.icimod.org/</a>>*<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><span style="color:rgb(0,0,153)">Have a nice day!</span><br>--<br><p style="line-height:115%"><b><span style="font-size:9.0pt;line-height:115%;color:#7f7f7f" lang="EN-GB">Mr. Khun San Aung</span></b></p><u><span style="font-size:9.0pt;line-height:115%;color:blue" lang="EN-GB"><a href="http://geoportal.icimod.org/" target="_blank"></a></span></u><u><span style="font-size:9.0pt;line-height:115%;color:#7f7f7f" lang="EN-GB"></span></u></div></div>
</div>