> >>begin immediate; insert; select max(id) from blah; commit; > >> > >> > > > >Or "select last_insert_rowid() from blah limit 1" > > > >Regards > > > > > > > Better yet > > select last_insert_rowid(); > > The from clause is not needed and may imply that SQLite keeps the > last > inserted rowid for each table, which it does not. The limit clause > is > also unnecessary since the last_insert_rowid function always returns > a single result.
Oh. Nifty. I would therefore be safe doing this: begin immediate; insert into master_table() values(); insert into related_table( master_id, data ) select last_insert_rowid(), 'stuff'; commit; But it would fail if I had multiple related tables? begin immediate; insert into master_table() values(); insert into related_table( master_id, data ) select last_insert_rowid(), 'stuff'; insert into related_table2( master_id, data ) select last_insert_rowid(), 'wrong id inserted here'; commit; The last_insert_rowid() would be the id for the last related table not the master table. __________________________________ Yahoo! Messenger Show us what our next emoticon should look like. Join the fun. http://www.advision.webevents.yahoo.com/emoticontest