Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Keith Medcalf, on Friday, November 15, 2019 03:50 PM, wrote... > > > How you would use bound parameters depends on what you are using to interface > with the sqlite3 database. > > https://www.sqlite.org/c3ref/bind_blob.html for the C interfaces. > > In something like python you would pass the

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Keith Medcalf
How you would use bound parameters depends on what you are using to interface with the sqlite3 database. https://www.sqlite.org/c3ref/bind_blob.html for the C interfaces. In something like python you would pass the bindings as a tuple to the execute method of the cursor: cr.execute(sql,

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Simon Slavin, on Thursday, November 14, 2019 06:48 PM, wrote... > > On 14 Nov 2019, at 10:27pm, Jake Thaw, on > > > Why not like this? > > > > insert into t (a, b, c, d, e, idate) > > SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY > > idate desc limit 1; > > Dammit. I

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Keith Medcalf, on Thursday, November 14, 2019 06:44 PM, wrote... > > > On Thursday, 14 November, 2019 15:27, Jake Thaw, on > > >Why not like this? > > >insert into t (a, b, c, d, e, idate) > >SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY > >idate desc limit 1; > > Or, if

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Jake Thaw, on Thursday, November 14, 2019 05:27 PM, wrote... > > Why not like this? > > insert into t (a, b, c, d, e, idate) > SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY > idate desc limit 1; Thanks. Yes, this is great! Darn it, I didn't think of this. Thanks again.

Re: [sqlite] Adding a record to a table with one value change

2019-11-15 Thread Jose Isaias Cabrera
Simon Slavin, on Thursday, November 14, 2019 05:18 PM, wrote... > > On 14 Nov 2019, at 10:06pm, Jose Isaias Cabrera, on > > > insert into t (a, b, c, d, e, idate) values > > ( > >(SELECT a FROM t WHERE a = 'p001' ORDER BY idate desc limit 1), > >(SELECT b FROM t WHERE a = 'p001' ORDER BY

Re: [sqlite] Adding a record to a table with one value change

2019-11-14 Thread Simon Slavin
On 14 Nov 2019, at 10:27pm, Jake Thaw wrote: > Why not like this? > > insert into t (a, b, c, d, e, idate) > SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY > idate desc limit 1; Dammit. I thought I had tried this, and received a syntax error. Now I see that it was

Re: [sqlite] Adding a record to a table with one value change

2019-11-14 Thread Keith Medcalf
On Thursday, 14 November, 2019 15:27, Jake Thaw wrote: >Why not like this? >insert into t (a, b, c, d, e, idate) >SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY >idate desc limit 1; Or, if using bound paramaters (and you should be): insert into t (a, b, c, d, e, idate)

Re: [sqlite] Adding a record to a table with one value change

2019-11-14 Thread Jake Thaw
Why not like this? insert into t (a, b, c, d, e, idate) SELECT a, b, c, 'y', e, '2019-02-12' FROM t WHERE a = 'p001' ORDER BY idate desc limit 1; On Fri, Nov 15, 2019 at 9:19 AM Simon Slavin wrote: > > On 14 Nov 2019, at 10:06pm, Jose Isaias Cabrera wrote: > > > insert into t (a, b, c, d, e,

Re: [sqlite] Adding a record to a table with one value change

2019-11-14 Thread Simon Slavin
On 14 Nov 2019, at 10:06pm, Jose Isaias Cabrera wrote: > insert into t (a, b, c, d, e, idate) values > ( >(SELECT a FROM t WHERE a = 'p001' ORDER BY idate desc limit 1), >(SELECT b FROM t WHERE a = 'p001' ORDER BY idate desc limit 1), >(SELECT c FROM t WHERE a = 'p001' ORDER BY