houssam_ballout Posted July 8, 2007 Share Posted July 8, 2007 Hello all,I'd a web form, and this form must enter data to multiple tables lets say now: 2 tables, (Voucher and Customer)CustomerID is a forgein key in Voucher Table, and Voucher Table has a voucherId in it, how can I insert both CustomerID and its information to the Customer Table and also insert the CustomerID to the Voucher table?Thanks in advance Link to comment Share on other sites More sharing options...
vijay Posted July 17, 2007 Share Posted July 17, 2007 Hi... First insert record in Customer table, and then use last inserted id like in php:mysql_insert_id.. after insert it to voucher table..Regards,Vijay Link to comment Share on other sites More sharing options...
Yahweh Posted July 17, 2007 Share Posted July 17, 2007 Hello all,I'd a web form, and this form must enter data to multiple tables lets say now: 2 tables, (Voucher and Customer)CustomerID is a forgein key in Voucher Table, and Voucher Table has a voucherId in it, how can I insert both CustomerID and its information to the Customer Table and also insert the CustomerID to the Voucher table?Thanks in advance declare @lastID intINSERT INTO Customer (columns) VALUES (values);set @lastID = scope_identity()INSERT INTO Voucher(CustomerID) VALUES (@lastID); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.