<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Trailing spaces in MySQL</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:23:57 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/comment-page-1/#comment-18810</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Thu, 30 Nov 2006 18:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/#comment-18810</guid>
		<description>Right Jay, 

You can use Binary or as I mentioned BLOB does not have this behavior.   The problem with using BINARY for comparison it becomes case sensitive of course and you may get in trouble with using your indexes. 

Stripping spaces is good practice however it is yet another step you need to think about.</description>
		<content:encoded><![CDATA[<p>Right Jay, </p>
<p>You can use Binary or as I mentioned BLOB does not have this behavior.   The problem with using BINARY for comparison it becomes case sensitive of course and you may get in trouble with using your indexes. </p>
<p>Stripping spaces is good practice however it is yet another step you need to think about.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/comment-page-1/#comment-18808</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Thu, 30 Nov 2006 18:40:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/#comment-18808</guid>
		<description>Unless, of course, you compare using BINARY:

mysql&gt; SELECT &quot;a &quot; = &quot;a&quot;;
+------------+
&#124; &quot;a &quot; = &quot;a&quot; &#124;
+------------+
&#124;          1 &#124; 
+------------+
1 row in set (0.00 sec)

mysql&gt; SELECT BINARY &quot;a &quot; = BINARY &quot;a&quot;;
+--------------------------+
&#124; BINARY &quot;a &quot; = BINARY &quot;a&quot; &#124;
+--------------------------+
&#124;                        0 &#124; 
+--------------------------+
1 row in set (0.00 sec)

I think, however, a best practice would be to have the application strip trailing spaces before insertion.  I can&#039;t think of a good reason *not* to do so...

Jay</description>
		<content:encoded><![CDATA[<p>Unless, of course, you compare using BINARY:</p>
<p>mysql&gt; SELECT &#8220;a &#8221; = &#8220;a&#8221;;<br />
+&#8212;&#8212;&#8212;&#8212;+<br />
| &#8220;a &#8221; = &#8220;a&#8221; |<br />
+&#8212;&#8212;&#8212;&#8212;+<br />
|          1 |<br />
+&#8212;&#8212;&#8212;&#8212;+<br />
1 row in set (0.00 sec)</p>
<p>mysql&gt; SELECT BINARY &#8220;a &#8221; = BINARY &#8220;a&#8221;;<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
| BINARY &#8220;a &#8221; = BINARY &#8220;a&#8221; |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
|                        0 |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
1 row in set (0.00 sec)</p>
<p>I think, however, a best practice would be to have the application strip trailing spaces before insertion.  I can&#8217;t think of a good reason *not* to do so&#8230;</p>
<p>Jay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/comment-page-1/#comment-16714</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 27 Nov 2006 18:13:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/#comment-16714</guid>
		<description>Sure, 

Check the manual here:
http://dev.mysql.com/doc/refman/5.0/en/char.html

I&#039;ve tested it myself and  storing &quot;a &quot; to CHAR(10) and reading it back gives &quot;a&quot; and gives LENGTH(col)=1  
VARCHAR would read &quot;a &quot; and LENGTH(col)=2     while both of them will retrieve  column with value &quot;a&quot; (no space in the end) if we use WHERE col=&quot;a &quot; (with space)</description>
		<content:encoded><![CDATA[<p>Sure, </p>
<p>Check the manual here:<br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/char.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/en/char.html</a></p>
<p>I&#8217;ve tested it myself and  storing &#8220;a &#8221; to CHAR(10) and reading it back gives &#8220;a&#8221; and gives LENGTH(col)=1<br />
VARCHAR would read &#8220;a &#8221; and LENGTH(col)=2     while both of them will retrieve  column with value &#8220;a&#8221; (no space in the end) if we use WHERE col=&#8221;a &#8221; (with space)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martijn Tonies</title>
		<link>http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/comment-page-1/#comment-16691</link>
		<dc:creator>Martijn Tonies</dc:creator>
		<pubDate>Mon, 27 Nov 2006 17:42:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2006/11/27/trailing-spaces-in-mysql/#comment-16691</guid>
		<description>Are you sure that CHARs has spaces that are invisible? Cause that would be wrong according to the SQL Standard. VARCHARs should be trimmed.</description>
		<content:encoded><![CDATA[<p>Are you sure that CHARs has spaces that are invisible? Cause that would be wrong according to the SQL Standard. VARCHARs should be trimmed.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
