Re: varchar problem
- From: "Tony" <tony23.no@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 20 Jun 2005 13:05:45 -0700
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@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: varchar problem
- From: Terry
- Re: varchar problem
- References:
- varchar problem
- From: Terry
- Re: varchar problem
- From: Geoff Berrow
- Re: varchar problem
- From: Terry
- varchar problem
- Prev by Date: Re: Do any of you have a good suggestion on a good PHP training book?
- Next by Date: Re: Mail()
- Previous by thread: Re: varchar problem
- Next by thread: Re: varchar problem
- Index(es):
Relevant Pages
|