Re: [sqlite] UPDATE in multiple same table

2008-03-23 Thread Emilio Platzer
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

Re: [sqlite] UPDATE in multiple same table

2008-03-23 Thread Igor Tandetnik
"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)

Re: [sqlite] UPDATE in multiple same table

2008-03-23 Thread Emilio Platzer
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

Re: [sqlite] UPDATE in multiple same table

2008-03-23 Thread Igor Tandetnik
"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

[sqlite] UPDATE in multiple same table

2008-03-23 Thread Emilio Platzer
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