|
Posted by Tony on 06/20/05 23:05
Terry wrote:
> Geoff Berrow wrote:
>> Where have you read that? A space is just another character. If you
>> want to strip them, use trim().
>>
> From page 123 of "PHP and MySQL for Dynamic Web Sites" by Larry
> Ullman: ---------
> Heading "Char vs. Varchar"
> One primary difference between the two is that anything stored as CHAR
> will always be stored as a string the length of the column (using
> spaces to pad it). Coversely, VARCHAR strings will only be as long as
> the stored string itself.
What that's saying is that CHAR will be padded - so if you have CHAR(5) and
put in "abc", it will be stored as "abc ".
If you enter " hello " into a VARCHAR, it will store a SEVEN-character
string - the following series of characters (delimited
by -) - -h-e-l-l-o- -, because that is the string it was given.
There is nothing in that saying that leading spaces in the string saved in
the VARCHAR will be trimmed.
> - a google search yielded simular results.
>
> The filename (row[0]) is varchar and has no extra spaces.
> Some of the entries (row[3]) have leading spaces - most do not.
> Additionaly, I did not put any spaces in - why should I have to strip
> them?
How is the data being entered? If it's through a form, a user could easily
enter a leading or trailing space.
Also, how are you writing the query?
--
Tony Garcia
Web Right! Development
tony.NO@webrightdevelopment.SPAM.com
Navigation:
[Reply to this message]
|