List:General Discussion« Previous MessageNext Message »
From:AESYS S.p.A. [Enzo Arlati] Date:February 28 2005 1:24pm
Subject:field varchar and char truncate the ended blank characters
View as plain text  
I got this problem:
I need to save in a varchar field a string wich can have the ended part
filled with blank character, and I need to restore the string in the same
way it was saved, ie. with the right number of ended blank characters.
Mysql truncate tha last blank characaters of a field

for example if I have a table like the one belowe and insert some field with
blank characters at the end , like "abc " or "  middle  ", when I read thei
field I get "abc" and "  middle".

create table pippo ( codice int, messaggio varchar(20), a char(20));

insert into pippo values( 1, "abc ", "123 " );
insert into pippo values( 2, "  middle  ", " MIDDLE " );
select codice, messaggio, length(messaggio), a, length(a) from pippo;
1          abc                 3         123                 3
2            middle            8          MIDDLE             7


There are some way to avoid the automatic deletion of the last blank
characters ?

Regards,
Enzo Arlati   enzo.arlati@stripped
AESYS Via Artigiani, 41  24060 Brusaporto (BG) - Italy
Tel. +39 (0)35.2924.182   Fax +39 (0)35 680030

Thread
field varchar and char truncate the ended blank charactersAESYS S.p.A. [Enzo Arlati]28 Feb
  • Re: field varchar and char truncate the ended blank charactersGleb Paharenko1 Mar
    • R: field varchar and char truncate the ended blank charactersAESYS S.p.A. [Enzo Arlati]1 Mar
      • Re: field varchar and char truncate the ended blank charactersMartijn Tonies1 Mar