Re: [sqlite] Help with complex UPDATE question

2010-07-24 Thread Black, Michael (IS)
I can think of several answers to your last question; #1 Your mileage may vary #2 Take the easiest way for you and see it works well. #3 Since SQL wasn't designed for vector math do it in your program -- probably MUCH clearer to anybody (including yourself) in the future. It shouldn't take mor

Re: [sqlite] Help with complex UPDATE question

2010-07-23 Thread peterwinson1
Jim, I see what you mean. Would it be faster then if I read the from the table, do the math in a program, and then insert the values back into the table? Or would it faster to amend the table as you suggest and use SQL UPDATE? I wonder. Jim Morris-4 wrote: > > AYou must add additional data

Re: [sqlite] Help with complex UPDATE question

2010-07-23 Thread Jim Morris
You must add additional data to the rows so you can refer to them unambiguously. table1 (KEY, COL1, ord) 0, 1,1 0, 2,2 1, 3,1 1, 4,2 2, 5,1 2, 6,2 3, 7,1 3, 8,2 On 7/23/2010 12:16 PM, peterwinson1 wrote: > Jim you maybe correct that I don't have enough data to unambiguously identify > the rows

Re: [sqlite] Help with complex UPDATE question

2010-07-23 Thread peterwinson1
Jim you maybe correct that I don't have enough data to unambiguously identify the rows. But just in case I was not very clear the first time. What I want to do is take the COL1 values of the first 2 rows [1, 2] and subtract them from the COL1 values, two rows at a time. so [1, 2] - [1, 2], then

Re: [sqlite] Help with complex UPDATE question

2010-07-23 Thread Gerry Snyder
On 7/23/2010 10:09 AM, Jim Morris wrote: > What you are trying to do is unclear to me. It seems that table1 > doesn't have enough data to unambiguously identify the rows. > > On 7/23/2010 8:03 AM, peterwinson1 wrote: >> Thanks Eric and Alan for your help. I tried to apply your code to my proble

Re: [sqlite] Help with complex UPDATE question

2010-07-23 Thread Jim Morris
What you are trying to do is unclear to me. It seems that table1 doesn't have enough data to unambiguously identify the rows. On 7/23/2010 8:03 AM, peterwinson1 wrote: > Thanks Eric and Alan for your help. I tried to apply your code to my problem > and it works to a limited extent because the p

Re: [sqlite] Help with complex UPDATE question

2010-07-23 Thread peterwinson1
Thanks Eric and Alan for your help. I tried to apply your code to my problem and it works to a limited extent because the problem is more complicated than the example I gave in the post. I tries to simplify my exact problem but that didn't work out. So here is the problem that I trying to solve

Re: [sqlite] Help with complex UPDATE question

2010-07-22 Thread Alan Chandler
On 22/07/10 23:38, peterwinson1 wrote: > > Hello, > > I have a some what complex question about UPDATE. I have the following > table > > table1 (KEY, COL1) > > 0, 1 > 1, 2 > 2, 3 > 3, 4 > > What I would like to do is to UPDATE COL1 by subtracting the COL1 value > where KEY = 0 from the COL1 value

Re: [sqlite] Help with complex UPDATE question

2010-07-22 Thread Eric Smith
peterwinson1 wrote: > Hello, > > I have a some what complex question about UPDATE. I have the following > table > > table1 (KEY, COL1) > > 0, 1 > 1, 2 > 2, 3 > 3, 4 > > What I would like to do is to UPDATE COL1 by subtracting the COL1 value > where KEY = 0 from the COL1 value of the current r