Tracey you are correct - I was assuming only one. -----Original Message----- From: ProfoxTech [mailto:[email protected]] On Behalf Of Tracy Pearson Sent: Saturday, 10 January 2015 9:14 AM To: [email protected] Subject: RE: Help with update
Darren wrote on 2015-01-09: > UPDATE stocks SET timesheets = 0 > UPDATE stocks SET timesheets = tsheets.qty FROM tsheets WHERE stocks.stCode > = tsheets.stCode > > -----Original Message----- From: ProfoxTech > [mailto:[email protected]] On Behalf Of Sytze de Boer Sent: > Saturday, 10 January 2015 8:43 AM To: [email protected] Subject: > Help with update > > Friends > I know this code stinks and I'm sure there's a much better way with UPDATE, > but I can't figure it out. > > sele stocks > repla all timesheets with 0 > > sele tsheets > go top > scan > sele stocks > seek tsheets.stcode > replace timesheets with timesheets+tsheets.qty > sele tsheets > endscan > > Can anyone help with this ? > > -- > Kind regards, > Sytze de Boer > Darren, If Memory serves, the Update command can lock the table header during the process. If there are multiple tsheets.stcode and your are combining (summing them) you may need to use a subquery instead of the table directly in the suggested Update command. Untested: UPDATE stocks SET timesheets = tsheetsum.qty ; FROM (select stcode, sum(qty) as qty from tsheets group by 1) as tsheetsum ; WHERE stocks.stCode = tsheetsum.stCode Tracy Pearson PowerChurch Software [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[email protected] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

