Subject RE: [firebird-support] read the next record of the table
Author Mercea Paul
Try this

UPDATE myTable m
SET m.field_b =
(
SELECT first 1 m2.field_a
from myTable m2
where m2.row_id > m.row_id
)

Regards,
Paul


> -----Original Message-----
> From: firebird-support@yahoogroups.com [mailto:firebird-
> support@yahoogroups.com] On Behalf Of Maurizio
> Sent: 13 June 2008 13:40
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] read the next record of the table
>
> hi ,
> ho can i update a field with the value of another field
> positioned in the next row , example :
>
> row_id | field_a | field_b
> 1 11
> 2 22
> 3 33
> 4 44
>
> table should be :
>
> row_id | field_a | field_b
> 1 11 22
> 2 22 33
> 3 33 44
> 4 44 null
>
> i tryed :
>
> UPDATE myTable m
> SET m.field_b =
> (
> SELECT m2.field_a
> from myTable m2
> where m2.row_id = m.row_id + 1
> )
>
> it doesn't work : all field_b values are null
>
> thanks
>
> Mauro
>
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>