val would have to be declared unique (have a unique index) in order for that to 
work as intended, otherwise it will insert as many rows as there are duplicate 
val values ...

> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Simon Slavin
> Sent: Sunday, 8 September, 2013 20:27
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Insert statement
> 
> 
> On 9 Sep 2013, at 3:17am, Joseph L. Casale <jcas...@activenetwerx.com>
> wrote:
> 
> > INSERT INTO table_a (val) VALUES ('xxxxxx');
> > INSERT INTO table_b (id, key, val)
> >       SELECT last_insert_rowid(), 'yyy', 'zzz';
> >
> > Just not sure how to perform 20 or 30 of those inserts into table_b
> after the one into table_a
> > yields the id value I need.
> 
> Look up the last_insert_rowid() you want and store it in your
> programming language.  That's what programming languages are for.  But
> if you want to do it less efficiently ...
> 
> Look it up each time you insert into table_b:
> 
> INSERT INTO table_b (id, key, val)
>       SELECT id, 'yyy', 'zzz' FROM table_a WHERE val='xxxxxx';
> 
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



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

Reply via email to