snipt

Ctrl+h for KB shortcuts

SQL

Replace part of a string - SQLite

UPDATE table SET field = replace( field, 'C:\afolder\', 'C:\anewfolder\' ) WHERE field LIKE 'C:\afolder\%';
https://snipt.net/embed/363b284eade735ee1a4a262b4c7dce59/
/raw/363b284eade735ee1a4a262b4c7dce59/
363b284eade735ee1a4a262b4c7dce59
sql
SQL
1
2019-08-21T02:40:31
True
False
False
/api/public/snipt/142674/
replace-part-of-a-string-sqlite
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">UPDATE</span> <span class="k">table</span> <span class="k">SET</span> <span class="n">field</span> <span class="o">=</span> <span class="k">replace</span><span class="p">(</span> <span class="n">field</span><span class="p">,</span> <span class="s1">&#39;C:\afolder\&#39;</span><span class="p">,</span> <span class="s1">&#39;C:\anewfolder\&#39;</span> <span class="p">)</span> <span class="k">WHERE</span> <span class="n">field</span> <span class="k">LIKE</span> <span class="s1">&#39;C:\afolder\%&#39;</span><span class="p">;</span> </span></pre></div> </td></tr></table>