Re: [sqlite] updating using a value from another table

2013-10-08 Thread dean gwilliam
JKL, Igor, Tom Thank you very much for the advice. It's very much appreciated and helps A LOT! Best Regards Dean ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] updating using a value from another table

2013-10-08 Thread dean gwilliam
Kurt, Keith Thanks very much for your help. It's very much appreciated. Best Regards Dean ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

[sqlite] updating using a value from another table

2013-10-07 Thread dean gwilliam
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

Re: [sqlite] updating using a value from another table

2013-10-07 Thread Rob Richardson
7:48 AM To: sqlite-users@sqlite.org 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

Re: [sqlite] updating using a value from another table

2013-10-07 Thread Simon Slavin
On 7 Oct 2013, at 1:59pm, Rob Richardson rdrichard...@rad-con.com wrote: gDb eval UPDATE itms SET std_nm=(SELECT std_nm FROM aliases as x WHERE raw_nm = x.raw_nm); What happens if you use the SQLite shell tool to open your database and execute this command ? Simon.

Re: [sqlite] updating using a value from another table

2013-10-07 Thread dean gwilliam
Simon, Rob Thanks very much for your responses. I downloaded and used the shell...it gives the same results i.e. the first std_itm fld in aliases irrespective of what the value of raw_fld is in itms SQLite version 3.8.0.2 2013-09-03 17:11:13 Enter .help for instructions Enter SQL statements

Re: [sqlite] updating using a value from another table

2013-10-07 Thread Rob Richardson
Subject: Re: [sqlite] updating using a value from another table Simon, Rob Thanks very much for your responses. I downloaded and used the shell...it gives the same results i.e. the first std_itm fld in aliases irrespective of what the value of raw_fld is in itms SQLite version 3.8.0.2 2013-09-03

Re: [sqlite] updating using a value from another table

2013-10-07 Thread Simon Slavin
On 7 Oct 2013, at 3:45pm, dean gwilliam mgbg25...@blueyonder.co.uk wrote: sqlite UPDATE itms SET std_nm=(SELECT std_nm FROM aliases as x WHERE raw_nm = x .raw_nm); looking at it without the 'AS' ... UPDATE itms SET std_nm=(SELECT std_nm FROM aliases WHERE raw_nm = aliases.raw_nm); I'm

Re: [sqlite] updating using a value from another table

2013-10-07 Thread dean gwilliam
RobR Sorry for the delay...I needed to regenerate the database which took several minutes and processes after I messed it up. Here's the completed itms table. I don't understand why sales is written to the std_nm column in itms when each rows corresponding raw_nm field does not appear in

Re: [sqlite] updating using a value from another table

2013-10-07 Thread dean gwilliam
Thanks Simon I tried that but it writes nothing to itms.std_nm ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Re: [sqlite] updating using a value from another table

2013-10-07 Thread dean gwilliam
I seem to have cracked it with a cut-down example package require sqlite3 set gDb {} set db_fl_nm [pwd]\\test.db ;# :memory: proc mbx {x} { set answer [tk_messageBox -message $x -type yesno -icon question] switch -- $answer { yes {} no exit } } proc mfl {x} {global

Re: [sqlite] updating using a value from another table

2013-10-07 Thread dean gwilliam
It's not working in my big program though so... I'll try to see what's different i.e. I'm getting nothing in itms.std_nm using the test program update query despite it working in my test program ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] updating using a value from another table

2013-10-07 Thread dean gwilliam
It's working now I just needed to use a capital first character in alias.raw_nm. Now it's working in the big program too. Simon, Rob...thanks for your help/reassurance ___ sqlite-users mailing list sqlite-users@sqlite.org

Re: [sqlite] updating using a value from another table

2013-10-07 Thread Kurt Welgehausen
Simon Slavin slav...@bigfraud.org wrote: On 7 Oct 2013, at 3:45pm, dean gwilliam mgbg25...@blueyonder.co.uk wrote: sqlite UPDATE itms SET std_nm=(SELECT std_nm FROM aliases as x WHERE raw_nm = x .raw_nm); looking at it without the 'AS' ... UPDATE itms SET std_nm=(SELECT std_nm FROM

Re: [sqlite] updating using a value from another table

2013-10-07 Thread James K. Lowden
On Mon, 07 Oct 2013 12:48:10 +0100 dean gwilliam mgbg25...@blueyonder.co.uk wrote: 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); Oh, so close! An update statement without a WHERE clause updates the whole table. In

Re: [sqlite] updating using a value from another table

2013-10-07 Thread Igor Tandetnik
On 10/7/2013 7:41 PM, James K. Lowden wrote: On Mon, 07 Oct 2013 12:48:10 +0100 dean gwilliam mgbg25...@blueyonder.co.uk wrote: 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); Oh, so close! An update statement without a

Re: [sqlite] updating using a value from another table

2013-10-07 Thread Keith Medcalf
: [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

Re: [sqlite] updating using a value from another table

2013-10-07 Thread ve3meo
Igor Tandetnik-2 wrote Or alternatively, without a WHERE clause: update a set i = coalesce((select i from b where b.a = a.a), i); What I have used similar to this is: UPDATE a SET i = ifnull((select i from b where b.a = a.a), i); Tom -- View this message in context: