Greetings!
I have this table,
create table t (n INTEGER PRIMARY KEY, a, b, c, d, e, idate);
insert into t (a, b, c, d, e, idate) values ('p001', 1, 2, 'n', 4,
'2019-02-11');
insert into t (a, b, c, d, e, idate) values ('p002', 2, 2, 'n', 4,
'2019-02-11');
insert into t (a, b, c, d, e, idate) values ('p003', 3, 2, 'n', 4,
'2019-02-11');
insert into t (a, b, c, d, e, idate) values ('p004', 4, 2, 'y', 4,
'2019-02-11');
insert into t (a, b, c, d, e, idate) values ('p005', 5, 2, 'y', 4,
'2019-02-11');
select * from t;
1|p001|1|2|n|4|2019-02-11
2|p002|2|2|n|4|2019-02-11
3|p003|3|2|n|4|2019-02-11
4|p004|4|2|y|4|2019-02-11
5|p005|5|2|y|4|2019-02-11
and I want to add a new record based on the p001 record. I only want to change
two values, d and idate. I can do this with this command,
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 idate desc limit 1),
'y',
(SELECT e FROM t WHERE a = 'p001' ORDER BY idate desc limit 1),
'2019-02-12'
);
Is there a simpler way? Thanks.
josé
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users