List:General Discussion« Previous MessageNext Message »
From:Jani Tolonen Date:October 6 1999 12:23pm
Subject:Trailing blanks get chopped away from 'strings'
View as plain text  
Jani Tolonen writes:
 > tobiasb@stripped writes:
 >  > >Description:
 >  > 	I have some strings ending with blank characters. They are
 >  > 	efficiently removed. The trailing blanks are relevant.
 >  > 
 >  > >How-To-Repeat:
 >  > mysql> create table blabbel ( blubbel varchar(255) );
 >  > Query OK, 0 rows affected (0.07 sec)
 >  > 
 >  > mysql> insert into blabbel values ('blubbel ');
 >  > Query OK, 1 row affected (0.04 sec)
 >  > 
 >  > mysql> select * from blabbel where blubbel='blubbel ';
 >  > 	+---------+
 >  > 	| blubbel |
 >  > 	+---------+
 >  > 	| blubbel |
 >  > 	+---------+
 >  > 	1 row in set (0.00 sec)
 >  > 
 >  > 	mysql> select * from blabbel where blubbel='blubbel';
 >  > 	+---------+
 >  > 	| blubbel |
 >  > 	+---------+
 >  > 	| blubbel |
 >  > 	+---------+
 >  > 	1 row in set (0.00 sec)
 >  > 
 >  > 	mysql> select * from blabbel where blubbel='blubbel      ';
 >  > 	+---------+
 >  > 	| blubbel |
 >  > 	+---------+
 >  > 	| blubbel |
 >  > 	+---------+
 >  > 	1 row in set (0.00 sec)
 >  > 
 >  > 
 >  > >Fix:
 >  > 	Sorry, studying the MySQL source code is far beyond the time I have.
 >  >   Tobias Brox (alias TobiX) - sysguy - +4722925871 - http://www.funcom.com/
 >  >   If an _urgent_ email is not acted upon within 10 minutes, you might try
 >  >   a _short_ mail to sms@stripped
 > 
 > 
 > Hi Tobias,
 > 
 > Would a tinyblob type instead of varchar(255) do the thing for you?
 > (They are same size) Blobs are case sensitive and the trailing
 > spaces remain. If you need to do case insensitive search from a blob,
 > you can use lcase() or ucase() in the where clause to change all the
 > characters in the field to upper case, or lower case and do the
 > test accordingly.
 > 

Or tinytext, if you want a field, which is always case insensitive.

- Jani

-- 
+-------------------------------------------------------------+
| TcX  ____  __     _____   _____  ___                        |
|     /*/\*\/\*\   /*/ \*\ /*/ \*\ |*|       Jani Tolonen     |
|    /*/ /*/ /*/   \*\_   |*|   |*||*|       jani@stripped   |
|   /*/ /*/ /*/\*\/*/  \*\|*|   |*||*|       Helsinki         |
|  /*/     /*/  /*/\*\_/*/ \*\_/*/ |*|_____  Finland          |
|  ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^                   |
|             /*/             \*\            Developers Team  |
+-------------------------------------------------------------+
Thread
Trailing blanks get chopped away from 'strings'tobiasb6 Oct
  • Re: Trailing blanks get chopped away from 'strings'Faisal Nasim6 Oct
    • Re: Trailing blanks get chopped away from 'strings'Tobias Brox7 Oct
      • Re: Trailing blanks get chopped away from 'strings'Bob Kline7 Oct
        • Re: Trailing blanks get chopped away from 'strings'Tobias Brox7 Oct
      • Re: Trailing blanks get chopped away from 'strings'Michael Widenius7 Oct
    • Re: Trailing blanks get chopped away from 'strings'Faisal Nasim7 Oct
      • Re: Trailing blanks get chopped away from 'strings'Michael Widenius8 Oct
    • Re: Trailing blanks get chopped away from 'strings'Tonu Samuel8 Oct
    • question on perl DBI _ListDBs functionJames H. Thompson8 Oct
  • Re: Trailing blanks get chopped away from 'strings'Carsten H. Pedersen6 Oct
  • Trailing blanks get chopped away from 'strings'Jani Tolonen6 Oct
    • Trailing blanks get chopped away from 'strings'Jani Tolonen6 Oct