On 19 Jun 2017, at 12:2, Keith Medcalf <kmedc...@dessus.com> wrote: > insert into filters (absid, filter_name, enabled, filter_order) > values (null, 'Untitled filter', 0, coalesce((select max(filter_order) from > filters)+1,1)) > > If you want the filter_order by filter_name then you would need: > > insert into filters (absid, filter_name, enabled, filter_order) > values (null, 'Untitled filter', 0, coalesce((select max(filter_order) from > filters where filter_name='Untitled filter')+1,1)) > > (you need the coalesce to make sure the initial value is 1, unless you have > defined the column in the table with a default of 1) > > -- > ˙uʍop-ǝpısdn sı ɹoʇıuoɯ ɹnoʎ 'sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
Thanks, Keith and Chris. I had actually tried a "select max(…", but without, it would seem, enough brackets. -- Cheers -- Tim _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users