Hi,

I'm sure this is just a beginner's question, but I have been unable to
find the answer elsewhere. As I am indeed just a beginner (wrt
SQL/sqlite), please bear with me...

Suppose I create two tables:

CREATE TABLE tblA (
   idA PRIMARY KEY UNIQUE
);
CREATE TABLE tblB (
   idB PRIMARY KEY UNIQUE,
   A NOT NULL
);

Now, I would like to add a number of rows to tblB, one row to tblA, and
map each new row in tblB to the new row in tblA by setting tblB.A to the
corresponding tblA.idA. The question is: How?

I guess I have to do something with last_insert_rowid(), but I'm not quite
sure what exactly... If I do an INSERT INTO tblA, the last_insert_rowid()
allows me to find the right idA in tblA. But then after the first INSERT
INTO tblB, it changes to reflect the new inserted row, so I cannot use it
for the next INSERT INTO tblB, unless I use it to find the right idA in
tblB. But that means I'd have to use one statement for the first INSERT
INTO tblB and different one for all others, which doesn't feel right.

Thanks!

Koen


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to