{"id":115,"date":"2007-03-01T16:32:35","date_gmt":"2007-03-01T21:32:35","guid":{"rendered":"http:\/\/softbeam.net\/hobby\/?p=115"},"modified":"2007-03-01T16:32:35","modified_gmt":"2007-03-01T21:32:35","slug":"mysql-string-replace","status":"publish","type":"post","link":"https:\/\/softbeam.net\/hobby\/?p=115","title":{"rendered":"mysql &#8211; string replace"},"content":{"rendered":"<p>example: replace &#8220;www.softbeam.net\/wordpress&#8221; in field &#8220;guid&#8221; with &#8220;www.softbeam.net\/softbeam&#8221; for table &#8220;wp_posts&#8221; in database &#8220;softbeam&#8221;<\/p>\n<p>show databases;<br \/>\nuse softbeam;<br \/>\nshow tables;<br \/>\nshow fields from wp_posts;<br \/>\nupdate wp_posts set guid = replace(guid,&#8221;www.www.softbeam.net\/wordpress&#8221;,&#8221;www.softbeam.net\/softbeam&#8221;);<\/p>\n<p>update wp_options set option_value = replace(option_value,&#8221;wordpress&#8221;,&#8221;sofbeam&#8221;);<br \/>\nupdate wp_posts set post_content = replace(post_content,&#8221;wordpress&#8221;,&#8221;softbeam&#8221;);<\/p>\n<p>examples :<\/p>\n<p>replace string in all records from a table :<br \/>\nupdate mytable set myfield =  replace (myfield, &#8220;one&#8221;, &#8220;two&#8221;);<br \/>\ndisplay a modified record set<br \/>\nSELECT REPLACE(myfield, &#8216;one&#8217;, &#8216;two&#8217;) from mytable;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>example: replace &#8220;www.softbeam.net\/wordpress&#8221; in field &#8220;guid&#8221; with &#8220;www.softbeam.net\/softbeam&#8221; for table &#8220;wp_posts&#8221; in database &#8220;softbeam&#8221; show databases; use softbeam; show tables; show fields from wp_posts; update wp_posts set guid = replace(guid,&#8221;www.www.softbeam.net\/wordpress&#8221;,&#8221;www.softbeam.net\/softbeam&#8221;); update wp_options set option_value = replace(option_value,&#8221;wordpress&#8221;,&#8221;sofbeam&#8221;); update wp_posts set post_content = replace(post_content,&#8221;wordpress&#8221;,&#8221;softbeam&#8221;); examples : replace string in all records from a table : update mytable &hellip; <a href=\"https:\/\/softbeam.net\/hobby\/?p=115\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;mysql &#8211; string replace&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":0,"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softbeam.net\/hobby\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}