Igor,
On Thu, Oct 24, 2013 at 12:57 PM, Igor Tandetnik <i...@tandetnik.org> wrote: > On 10/24/2013 3:23 PM, Igor Korot wrote: > >> Will this query work: >> >> UPDATE a SET a.field1 = (SELECT b.field1 FROM b AS myfield), a.field2 = >> myfield... >> >> or I will have to repeat subquery for a.field2? >> > > I'm pretty sure you will have to repeat the subquery. In your statement, > myfield is an (unused) alias for table b, not for a value produced by the > subquery (which I don't know of any way to name or reuse). > Well, let me try to explain myself. Consider following schema: CREATE TABLE players( playerid INTEGER, name TEXT, rank INTEGER, PRIMARY KEY playerid); CREATE TABLE leagueplayers(playerid INTEGER, leagueid INTEGER, original_rank INTEGER, current_rank INTEGER); The players table is populated. What I'm trying to do is to populate the second table with the last 2 fields: original_rank and current_rank. So I was thinking of something like this: UPDATE leagueplayers SET original_rank = (SELECT rank FROM players AS a), current_rank= a WHERE players.playerid = leagueplayers.playerid; But I guess this query will not work. ;-) Any idea how to make the proper query? Thank you. -- > Igor Tandetnik > > > ______________________________**_________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<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