我需要將2條記錄插入到2個不同的表格中。問題是這兩個記錄將具有相同的ID。 例如:我需要在不同表格中插入2條記錄,
我有我的Mannto表,其IdMan和oters字段。我也有我的服務表,其IdServ。
我能做些什麼來使這個平等?我正在使用Postgre。在Mannto表的ID是串行的,我需要使用一個作爲服務表的外鍵
我嘗試以下,但它不工作:
Insert into Mannto (idMan, field 1 field2 ...etc)
values (default, 'f1', 'f2'...etc)
Insert into Service (idServ, fkMannto, field1...etc)
values (default, (in this part I need the same ManntoId called idMan), 'f1')
感謝您的幫助你可以提供!
我試過的,但有一些問題,但非常感謝反正:)回答 – Jeil