Johnny Cheuk
Johnny Cheuk

Reputation: 237

If I want to insert many records in one record from other table, how can I do that?

Alright, my situation was like this:

My database have two tables, one of the table is named DB_TABLE, which is used to store some claim records, which contains the following fields: claimdate, claimtype, claimcurrency, claimcost, claimdescription.

In my other table, which is named DBATTACHMENT_TABLE, is used to store images, and the field name is claimattachment.

The record table updates when I hit the submit button, and in the meantime, I wish I could updates my attachment table as well. But if I need to add more than 1 attachment in each record, I need a parent ID to create relationship between two tables. How can I get which row I was creating at the record table before I hit the submit button, so that I can insert the parent ID into my attachment table at the same time? Please help!

Upvotes: 0

Views: 70

Answers (1)

Nigam Patro
Nigam Patro

Reputation: 2770

For that, you also need to add an ID to the DB_TABLE which is of type AUTOINCREMENT, at first create a add a row in the DB_TABLE. After adding it, make a select query to the table for the last row, and you will get the ID from DB_TABLE and using that ID continue with your attachment table operation.

Upvotes: 1

Related Questions