Re: SELECT does not find table created by itself

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT does not find table created by itself
Date: 2010-01-04 08:29:02
Message-ID: 9837222c1001040029l705427eeg84cefcde8656983b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/1/2 Andrus <kobruleht2(at)hot(dot)ee>:
> select * FROM (select 1 as a) t2 left join t2 t3 ON TRUE
>
> causes error
>
> ERROR:  relation "t2" does not exist
>
> How to fix so that table t2 is created only once ?

Not entirely sure if this is what you're looking for, but I think a
CTE can solve your problem:
WITH t2 AS (SELECT 1 AS a)
SELECT * FROM t2 LEFT JOIN t3 ON TRUE

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2010-01-04 08:29:18 Re: Using autogenerated primary key in transaction
Previous Message John R Pierce 2010-01-04 08:25:41 Re: Using autogenerated primary key in transaction