<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>database Archivi - Cesare Bordi | Innovation Manager &amp; Back-end Developer</title>
	<atom:link href="https://www.cesarebordi.it/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.cesarebordi.it/tag/database/</link>
	<description>Innovare con soluzioni software efficaci e gioco di squadra</description>
	<lastBuildDate>Thu, 21 May 2020 15:34:19 +0000</lastBuildDate>
	<language>it-IT</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.2</generator>

<image>
	<url>https://www.cesarebordi.it/wp-content/uploads/2016/02/CB-logo-88x88.png</url>
	<title>database Archivi - Cesare Bordi | Innovation Manager &amp; Back-end Developer</title>
	<link>https://www.cesarebordi.it/tag/database/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>MySql: cerca e sostituisci in una query per web developer</title>
		<link>https://www.cesarebordi.it/mysql-cerca-e-sostituisci-query-web-developer/</link>
					<comments>https://www.cesarebordi.it/mysql-cerca-e-sostituisci-query-web-developer/#respond</comments>
		
		<dc:creator><![CDATA[cesarebordi]]></dc:creator>
		<pubDate>Fri, 12 Aug 2016 17:21:18 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[web developer]]></category>
		<category><![CDATA[web master]]></category>
		<category><![CDATA[web project]]></category>
		<guid isPermaLink="false">http://www.cesarebordi.it/?p=381</guid>

					<description><![CDATA[<p>Scenario: nel routine di un web developer o di un web master capita spesso di dover fare un cerca e sostituisci con il database MySql. Credo che qualsiasi...</p>
<p>L'articolo <a href="https://www.cesarebordi.it/mysql-cerca-e-sostituisci-query-web-developer/">MySql: cerca e sostituisci in una query per web developer</a> sembra essere il primo su <a href="https://www.cesarebordi.it">Cesare Bordi | Innovation Manager &amp; Back-end Developer</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span style="text-decoration: underline;">Scenario</span>: nel routine di un <strong>web developer</strong> o di un <strong>web master </strong>capita spesso di dover fare un <strong>cerca e sostituisci</strong> con il <strong>database MySql</strong>. <span id="more-381"></span></p>


<p>Credo che qualsiasi <strong>programmatore</strong> si sia trovato nella condizione di dover <strong>cercare</strong> un determinato <strong>valore di un campo</strong> ricorrente in molteplici<strong> record</strong> per <strong>sostituirlo</strong> con uno diverso.</p>



<p>Diciamo ad esempio di voler <strong>sostituire in una tabella</strong> di dati anagrafici il termine &#8220;maschio&#8221; con &#8220;M&#8221; nel campo &#8220;genere&#8221;.</p>



<p>Problema: come fare quindi per eseguire un &#8220;<strong>cerca e sostituisci</strong>&#8221; in massa su tutti i <strong>record interessati</strong> della tabella MySql?</p>



<p>Soluzione: detto fatto, basta sfruttare l&#8217;apposita <strong><a href="http://dev.mysql.com/doc/refman/5.7/en/string-functions.html" target="_blank" rel="noreferrer noopener">string function REPLACE</a> di MySQL</strong> opportunatamente combinata con un <a href="http://dev.mysql.com/doc/refman/5.7/en/update.html" target="_blank" rel="noreferrer noopener"><strong>UPDATE</strong></a>:</p>



<p><strong>UPDATE</strong> `<em>nomeTabella`</em> <strong>SET</strong> `<em>nomeCampo`</em> = <strong>REPLACE</strong>(`<em>nomeCampo`</em>, &#8216;<em>cosaTrovare</em>&#8216;, &#8216;<em>cosaSostituire</em>&#8216;);</p>



<p>Se l&#8217;applichiamo al nostro esempio otterremo:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
UPDATE `Anagrafica` SET `genere` = REPLACE(`genere`, 'maschio', 'M');
</pre></div><p>L'articolo <a href="https://www.cesarebordi.it/mysql-cerca-e-sostituisci-query-web-developer/">MySql: cerca e sostituisci in una query per web developer</a> sembra essere il primo su <a href="https://www.cesarebordi.it">Cesare Bordi | Innovation Manager &amp; Back-end Developer</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.cesarebordi.it/mysql-cerca-e-sostituisci-query-web-developer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
