Re: Select statement - Mailing list pgsql-general

From Richard Huxton
Subject Re: Select statement
Date
Msg-id 009501c0e29c$280d26e0$1001a8c0@archonet.com
Whole thread Raw
In response to Select statement  (dave go <godave621@yahoo.com>)
List pgsql-general
From: "dave go" <godave621@yahoo.com>

> Hi,
>
> I am trying create a new table A from table B. On B
> (b1, b2, b3, b4 ) I would like create a table A (a1,
> a2, a3) where a2 is b2 and b3.

create table foo(a serial, b text);

select a, substr(b,1,strpos(b,' ')-1) as firstname, substr(b,strpos(b,'
')+1) as lastname into bar from foo;

will create a table bar. You will need to add your own sequences etc. later.

Note - CHECK YOUR NAMES FIRST - this will only work with exactly two names
separated by one space.

- Richard Huxton


pgsql-general by date:

Previous
From: Dirk Lutzebaeck
Date:
Subject: Load balancing lots of simultaneous clients or queries?
Next
From: Ludovico Romano
Date:
Subject: how to convert Access to PG unless odbc driver(with sql file)