Mayhaps,
update itms
set std_nm = (select std_nm
from aliases
where raw_nm=itms.raw_nw)
where exists (select 1
from aliases
where raw_nm=itms.raw_nw);
which translates to english as:
for each row in itms where there exists a row in aliases where
aliases.raw_nm=itms.raw_nm
set itms.raw_nm to aliases.std_nm where
aliases.raw_nm=itms.raw_nm
This
UPDATE itms SET std_nm=(SELECT std_nm FROM aliases as x WHERE raw_nm = x.raw_nm)
translates to english as:
for each row in itms set itms.std_nm to the std_nm located in the first row of
aliases where aliases.raw_nm=aliases.raw_nm
>-----Original Message-----
>From: [email protected] [mailto:sqlite-users-
>[email protected]] On Behalf Of dean gwilliam
>Sent: Monday, 7 October, 2013 05:48
>To: [email protected]
>Subject: [sqlite] updating using a value from another table
>
>Here it is
>tbl itms (std_nm text, raw_nm text)
>tbl aliases (std_nm text, raw_nm text)
>
>Id like to whip through table itms which has a blank col std_nm and fill
>in as many fields as I can
>by
>reading each itms' raw_nm fld
>finding any matching rec (with the same raw_nm value) in aliases
>updating the std_nm fld in itms with corresponding std_nm value in the
>matching fld in aliases
>
>Here's my miserable attempt
>gDb eval "UPDATE itms SET std_nm=(SELECT std_nm FROM aliases as x WHERE
>raw_nm = x.raw_nm);"
>
>Any help much appreciated
>_______________________________________________
>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