Re: [GENERAL] need help separating a field

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: Kevin Heflin <kheflin(at)shreve(dot)net>, "PGSQL-General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] need help separating a field
Date: 1999-02-11 21:05:21
Message-ID: 36C34611.BBF3169F@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Well, I once split up a bunch of multiline addresses with lines like
this:

select "PerIndex",substr("addr",1,(strpos("addr",'\n')- 1)) as addr,
substr("addr",(str
pos("addr",'\n')+1)) as addr2 into tmp2_addr from tmp_addr;

so, try something like (untested):

select substr(username_password,1,(strpos(username_password,'/')-1)) as
username, substr(username_password,(strpos(username_password,'/')+1)) as
password into new_table from table;

Kevin Heflin wrote:
>
> I have a table with a field of 'username_password' where the data is in
> the format of:
>
> username/password
>
> what I would really like to do, is create a new field of 'username' and
> another of 'password' and with some magic SQL statement select all from
> username_password, and spit up the pair, and insert them back into the
> newly created 'username' and 'password' fields.
>
> Is this even possible? and if so, would anyone be willing to give me a
> hint?
>
> Kevin
>
> --------------------------------------------------------------------
> Kevin Heflin | ShreveNet, Inc. | Ph:318.222.2638 x103
> VP/Mac Tech | 333 Texas St #619 | FAX:318.221.6612
> kheflin(at)shreve(dot)net | Shreveport, LA 71101 | http://www.shreve.net
> --------------------------------------------------------------------

--
Ross J. Reedstrom, Ph.D., <reedstrm(at)rice(dot)edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Doliov 1999-02-11 21:08:12 Subject: Re: [GENERAL] A book for PgSQL? A need? yes? no?
Previous Message Kevin Heflin 1999-02-11 20:46:19 need help separating a field