<?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>Deec.it &#187; latin1_bin</title>
	<atom:link href="http://www.deec.it/tag/latin1_bin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deec.it</link>
	<description>Le Guide Pratiche Dell&#039;Informatica</description>
	<lastBuildDate>Sun, 04 Sep 2011 16:52:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Mysql: Illegal mix of collations</title>
		<link>http://www.deec.it/2009/11/15/mysql-illegal-mix-of-collations/</link>
		<comments>http://www.deec.it/2009/11/15/mysql-illegal-mix-of-collations/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 22:45:04 +0000</pubDate>
		<dc:creator>loade</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[collations]]></category>
		<category><![CDATA[Illegal mix of collations]]></category>
		<category><![CDATA[latin1_bin]]></category>
		<category><![CDATA[latin1_general_ci]]></category>

		<guid isPermaLink="false">http://www.deec.it/?p=2111</guid>
		<description><![CDATA[



Un errore che può capitare, quando si effettuano query su due db o due tabelle con una collations differente, è il seguente:
ERROR 1267 (HY000): Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation &#8216;=&#8217;
Questo errore indica che i due campi su cui stiamo effettuando la query hanno una collations differente e non compatibile. Facciamo qualche [...]]]></description>
			<content:encoded><![CDATA[<!-- AdSense Now! V1.77 -->
<!-- Post[count: 3] -->
<div class="adsense adsense-leadin" style="text-align:center;margin: 12px;"><script type="text/javascript"><!--
google_ad_client = "pub-5841373120371067";
/* 468x60, creato 22/09/09 M&amp;P */
google_ad_slot = "8731175604";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>Un errore che può capitare, quando si effettuano query su due db o due tabelle con una collations differente, è il seguente:</p>
<blockquote><p>ERROR 1267 (HY000): Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation &#8216;=&#8217;</p></blockquote>
<p>Questo errore indica che i due campi su cui stiamo effettuando la query hanno una collations differente e non compatibile. Facciamo qualche esempio ecco la nostra tabella:</p>
<blockquote><p>show create table a;</p>
<p>CREATE TABLE `a` (<br />
`campo1` varchar(64) character set latin1 collate latin1_bin NOT NULL default &#8221;<br />
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |</p>
<p>show create table b;</p>
<p>CREATE TABLE `b` (<br />
`campo2` varchar(255) NOT NULL default &#8221;<br />
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |</p></blockquote>
<p>La tabella b non avendo alcuna collations impostata, prenderà quella di default, ovvero:</p>
<blockquote><p>collate latin1_general_ci</p></blockquote>
<p>Ora se andiamo a fare una query che preleva i dati da entrambe le tabelle, otterremo il seguente errore:</p>
<blockquote><p>SELECT *  FROM a,b WHERE campo1 = campo2;</p>
<p>ERROR 1267 (HY000): Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation &#8216;=&#8217;</p></blockquote>
<p>Ora per risolvere il problema forziamo la collate  <strong>latin1_bin</strong> in <strong>latin1_general_ci:</strong></p>
<blockquote><p>ALTER TABLE a character set latin1 collate latin1_general_ci , modify column campo1 varchar(64) character set latin1 collate latin1_general_ci  NOT NULL;</p></blockquote>
<p>A questo punto lo show create table ci mostrerà la nuova collate impostata per il campo campo1 e la query che prima ci restituiva l&#8217;errore ora sarà eseguita correttamente.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deec.it/2009/11/15/mysql-illegal-mix-of-collations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

