Hi, I have two table with a one to many relationship between them.
Basically the first table, I need to insert a user_id and a date, and in the second table I need to insert the primary_id of the first table (of the record that was just created) and additional values.
What is the best way of doing this?
Basically, at the moment I have:
INSERT INTO payment_details (dt_created,user_id) VALUES (getdate(),508)
SELECT payment_id From payment_details ORDER BY DESC -- To get the last entered value
INSERT INTO user_custom_payment (payment_id,description,dt_from,dt_to,dt_created,active,amount)
VALUES()...
Is this the only way or is there a better method? Can you do it in the one sql statement?
Thanks,