Re: [GENERAL] print/return only the first X chars of a varchar column?

2009-09-02 Thread kalyan s
Hi,
I think you can use the overlay function to do this.

http://www.postgresql.org/docs/current/static/functions-string.html

create table t1 (f char(10));
insert into t1 values ('abcdefg'),('hijklmno');
-- the below cmd will display only the first 2 characters of f.
-- if you want trim the spaces :) after this. 
select overlay(f placing ' ' from 3 to 10);

Regards
kalyan



***
This e-mail and attachments contain confidential information from HUAWEI,
which is intended only for the person or entity whose address is listed
above. Any use of the information contained herein in any way (including,
but not limited to, total or partial disclosure, reproduction, or
dissemination) by persons other than the intended recipient's) is
prohibited. If you receive this e-mail in error, please notify the sender by
phone or email immediately and delete it!

-Original Message-
From: pgsql-general-ow...@postgresql.org
[mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Kevin Kempter
Sent: Monday, August 31, 2009 8:19 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] print/return only the first X chars of a varchar column?

Hi all;

I'm selecting from a table that has a varchar(1000) but I only want to
display 
the firs 20 characters.  Looked at the string functions in the docs but
nothing 
jumped out...

Suggestions?


Thanks in advance


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] print/return only the first X chars of a varchar column?

2009-08-31 Thread Kevin Kempter
Hi all;

I'm selecting from a table that has a varchar(1000) but I only want to display 
the firs 20 characters.  Looked at the string functions in the docs but nothing 
jumped out...

Suggestions?


Thanks in advance


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


Re: [GENERAL] print/return only the first X chars of a varchar column?

2009-08-31 Thread Adrian Klaver
On Monday 31 August 2009 7:49:12 am Kevin Kempter wrote:
 Hi all;

 I'm selecting from a table that has a varchar(1000) but I only want to
 display the firs 20 characters.  Looked at the string functions in the docs
 but nothing jumped out...

 Suggestions?


 Thanks in advance

substring(string [from int] [for int])  


-- 
Adrian Klaver
akla...@comcast.net

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general