I'm looking at a database that has 3 tables into which I have to insert data:
resource
id (AUTO_INCREMENT)
name
resource_item
id (AUTO_INCREMENT)
name
resource_id (FK ref resource.id)
resource_item_business_function
id (AUTO_INCREMENT)
business_function_name
resource_item_id
What I'm struggling with is the fact that this must be scripted. I'm only inserting 1 resource
record so I can script the insert into the resource
table easily enough. I have ~20 resource_item
records to insert for that resource
and I can even do that easily enough using the LAST_INSERT_ID()
function. The question is...how do I insert into resource_item_business_function
?
I have no idea how to insert the proper resource_item_id
into each resource_item_business_function
record. Any thoughts would be much appreciated.