List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:August 24 1999 2:50pm
Subject:Re: linebreaks inside a field!
View as plain text  
At 3:03 PM +0000 8/24/99, Venky wrote:
>Hi !
>
>Consider this small example...
>
>********************************************************
>mysql> create table test(
>    -> field1 varchar(20),
>    -> field2 char(20));
>
>Query OK, 0 rows affected (0.01 sec)
>
>mysql> insert into test values('this is
>    '> b1','this is b2');
>********************************************************
>
>In the insert example, i am using line breaks because in some tables, the
>entry is very long, and hence, i have to break it into multiple lines. The
>problem is that the line break gets stored, along with the values. The
>above looks like this:
>
>+------------+------------+
>| field1     | field2     |
>+------------+------------+
>| this is a1 | this is a2 |
>| this is
>b1 | this is b2 |
>+------------+------------+
>
>1. Is there anyway the new line in the field can be avoided please?
>2. If the line break cannot be avoided, can this create problems in say,
>while retreiving data from PHP?
>3. How can one get rid of the carriage return in the field while doing a
>select.... into outfile?


After inserting the data, run this query to delete the newlines:

UPDATE test SET b1=REPLACE(b1,"\n",""), b2=REPLACE(b2,"\n","")

-- 
Paul DuBois, paul@stripped
Thread
linebreaks inside a field!Venky24 Aug
  • linebreaks inside a field!sinisa24 Aug
  • Re: linebreaks inside a field!Paul DuBois24 Aug