On Thursday, 14 November, 2019 15:27, Jake Thaw <jaket...@gmail.com> 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) 
       select ?, b, c, ?, e, ?
         from t 
        where a = ?1 
     order by idate desc 
        limit 1;

then you bind the three parameters a, d, idate.

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.

-- 
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.




_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to