You need brackets around the scalar value that is returned by the correlated subquery
update table1 set name=(select name from table2 where table2.id=table1.id); This will update the name field in EVERY ROW of table1 with the value of name retrieved from table2, or with null if no matching row is found (and have an error thus doing nothing if name cannot be set to null). If there are multiple matching rows then one name value will be selected at random from amongst the candidate rows. If this is not the precise result you are looking for you may need to add more clauses (eg WHERE) to limit the update candidates and/or to ensure that only one value is returned from the correlated subquery. --- () ascii ribbon campaign against html e-mail /\ www.asciiribbon.org > -----Original Message----- > From: [email protected] [mailto:sqlite-users- > [email protected]] On Behalf Of YAN HONG YE > Sent: Tuesday, 08 January, 2013 20:13 > To: [email protected] > Subject: [sqlite] update value from another tow tables > > updat table1 set name=selet name from table2 where table2.id=table1.id; > > this command couldn't work, how to update this status? > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

