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, ('p0001', 5, '2014-02-23')) Basically it allows you to substitute values provided by your program into the sql statement rather than compose the sql statement dynamically possibly leading to injection problems. https://xkcd.com/327/ -- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> On >Behalf Of Jose Isaias Cabrera >Sent: Friday, 15 November, 2019 06:20 >To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> >Subject: Re: [sqlite] Adding a record to a table with one value change > > >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 using bound paramaters (and you should be): > >What are bound parameters? And where can I read about these? I see >people use the ? all the time, and I have no idea how that works. > >> insert into t (a, b, c, d, e, idate) >> select ?, b, c, ?, e, ? >> from t >> where a = ?1 >> order by idate desc >> limit 1; >> >> then you bind the three parameters a, d, idate. > >How do I bind the three parameters? > >> Whether you want "order by idate desc" or "order by idate" depends on >whether you want the newest or oldest record to be the template. > >Yep, this I know. And yes, I want the newest, so descending is what I >want. Thanks. > >josé >_______________________________________________ >sqlite-users mailing list >sqlite-users@mailinglists.sqlite.org >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users