たとえば、2 つのテーブルを持つデータベースがあります。最初のテーブル (table1) には次のものがあります。
userId int not null auto_increment primary key
userEmail
userPassword
userId は、自動インクリメントされる主キーです。次のテーブル (table2) には次のものがあります。
userProfileId int not null auto_increment primary key
userAge
userGender
userId
userId (table2 から) は、table1(userId) を参照する外部キーです。両方のテーブルのすべての情報を INSERT INTO し、table2 の userId が table1 から参照する主キーを自動的に取得する方法はありますか? または、テーブルごとに複数の INSERTS を実行し、外部キーを明示的に同じ値にする必要がありますか。