Re: [sqlite] updating records in table A from joined records intable B

2011-04-01 Thread Robert Poor
On Fri, Apr 1, 2011 at 20:13, Igor Tandetnik  wrote:
> Or
> update table_a set avalue=coalesce(
>    (select bvalue from table_b where akey=bkey), avalue);

Nice.  But if table_b.value is null, it won't get copied into table_a.
 That would be a unexpected.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] updating records in table A from joined records intable B

2011-04-01 Thread Igor Tandetnik
David Garfield  wrote:
> UPDATE table_a SET avalue=(SELECT bvalue FROM table_b WHERE akey=bkey)
> WHERE EXISTS(SELECT 1 FROM table_b WHERE akey=bkey);

Or

update table_a set avalue=coalesce(
(select bvalue from table_b where akey=bkey), avalue);

-- 
Igor Tandetnik

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