Search Postgresql Archives

Re: Copying a column into a temp. table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 1, 2010 at 10:02 AM, Adrian Klaver <adrian.klaver@xxxxxxxxx> wrote:
On Friday 01 October 2010 6:54:09 am Alexander Farber wrote:
> How do you copy a column from table please?
> I'm trying with PostgreSQL 8.1.21/CentOS 5.5:
 
> select topic_id from phpbb_topics where forum_id=5 and topic_poster=1
> and age(to_timestamp(topic_time))>interval '14 days' into old_topics;
> psql:clean-forum.sql:6: ERROR:  syntax error at or near "into" at character
> 124 psql:clean-forum.sql:6: LINE 1: ...
> age(to_timestamp(topic_time))>interval '14 days' into old_t...
 
> Of course "select ... into" doesn't work, but how should I do it?
> Can't find in http://www.postgresql.org/docs/8.1/static/
>
> Thank you
> Alex

http://www.postgresql.org/docs/8.1/interactive/sql-insert.html

Short answer is
insert into my_temp_table select a,b from mytable;

Or as Gabriele said, CREATE TEMP TABLE mytable AS SELECT should also work.

Regards,
--
gurjeet.singh
@ EnterpriseDB - The Enterprise Postgres Company
http://www.EnterpriseDB.com

singh.gurjeet@{ gmail | yahoo }.com
Twitter/Skype: singh_gurjeet

Mail sent from my BlackLaptop device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux