Thank's It works also in PostgreSQL!
Emilio Platzer
Igor Tandetnik escribió:
> "Emilio Platzer" <[EMAIL PROTECTED]> wrote
> in message
> news:[EMAIL PROTECTED]
>> I try (and not works):
>>
>> CREATE TABLE nodes(
>> id integer primary key,
>> father_id integer,
>> depth integer);
>> INSERT
"Emilio Platzer" <[EMAIL PROTECTED]> wrote
in message
news:[EMAIL PROTECTED]
> I try (and not works):
>
> CREATE TABLE nodes(
> id integer primary key,
> father_id integer,
> depth integer);
> INSERT INTO nodes (id,father_id,depth) VALUES (9,null,1);
> INSERT INTO nodes (id,father_id,depth)
I try that solution but don't work. The reason is that in the subquery if
a field don't prefix with an alias (or a table name) the parser supouses
that was of de first table [[[--- Sorry about my poor Englis ---]]]
I try (and not works):
CREATE TABLE nodes(
id integer primary key,
father_id
"Emilio Platzer" <[EMAIL PROTECTED]> wrote
in message
news:[EMAIL PROTECTED]
> I want to UPDATE a field of one table with data of rows of the same
> table.
>
> For example to calculate the depth of a node in a tree
>
> update nodes as s set s.depth=
>(select f.depth+1
> from nodes as f
I want to UPDATE a field of one table with data of rows of the same table.
For example to calculate the depth of a node in a tree
update nodes as s set s.depth=
(select f.depth+1
from nodes as f
where f.id=s.father_id)
where s.depth is null;
I could do this in a ugly
5 matches
Mail list logo