pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rajesh Kumar Mallah <mallah@trade-india.com>
To: Sethi Tarun-ETS017 <Tarun.Sethi@motorola.com>
To: pgsql-sql@postgresql.org
Subject: Re: newline character in SQL
Date: Sat, 22 Mar 2003 15:33:44 +0530
Message-ID: <200303221533.44147.mallah@trade-india.com> (raw)
In-Reply-To: <D7A316136BB6D411A777001083FD087106DCFE90@plnt056.comm.mot.com>
References: <D7A316136BB6D411A777001083FD087106DCFE90@plnt056.comm.mot.com>



Use replace function as documented in 
http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=functions-string.html

eg in your case you can do:
Select name,  replace(name, '\n' , '') as straight_name , comments ,
replace(comments, '\n' , '') as straight_comment from table where comment like '%Fine%';


please not that replace function is inbuilt in postgresql 7.3.x , 
i previous versions i am not sure , but there is a work around for older
versions.

Regds
Mallah.


On Friday 21 Mar 2003 8:46 am, Sethi Tarun-ETS017 wrote:
> How can I remove the newline character from the value of a column.
> 
> For Example:
> Select name, comments from table where comment like '%Fine%';
> Results:
> NAME		COMMENTS
> John M.	This was a
> 		Fine piece of 
> 		work.
> 
> Above, I'd like the Results to appear:
> NAME		COMMENTS
> John M.	This was a Fine piece of work.
> 
> I tried substr, instr, hedged right ... but can't get it to work.
> 
> Any help will be greatly appreciated.
> 
> Regards
> TS
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 
> 

-- 
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)

Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.




view thread (4+ messages)  latest in thread

Message-ID: <200303221533.44147.mallah@trade-india.com>
Permalink:  ../200303221533.44147.mallah@trade-india.com/
Also on:    postgresql.org/message-id/200303221533.44147.mallah@trade-india.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mallah@trade-india.com, Tarun.Sethi@motorola.com
  Subject: Re: newline character in SQL
  In-Reply-To: <200303221533.44147.mallah@trade-india.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox