Hi Igor,

Many thanks for that.

For this example I'm updating a single column (c2). If I needed to update
multiple columns in the table would I need to use the SELECT construct for
each column?

Cheers,
Dave


Ward Analytics Ltd - information in motion
Tel: +44 (0) 118 9740191
Fax: +44 (0) 118 9740192
www: http://www.ward-analytics.com

Registered office address: The Oriel, Sydenham Road, Guildford, Surrey,
United Kingdom, GU1 3SR
Registered company number: 3917021 Registered in England and Wales.

-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik
Sent: 08 June 2013 20:01
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Updating a table from itself

On 6/8/2013 2:51 PM, Dave Wellman wrote:
> update t1 from (select c1,c2 from t1) as dt1 set c2 = dt1.c2 where 
> t1.c1 = dt1.c2 - 1;

update t1 set c2 = coalesce((select c2 from t1 dt1 where t1.c1 = dt1.c2
- 1), c2);

--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to