[EMAIL PROTECTED] wrote:
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.

I'm not sure I understand the problem. Can't you insert into A, retrieve the last ID into a variable in your program, then use the value of this variable for all subsequent inserts into B?

Igor Tandetnik

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

Reply via email to