在我的数据库中,所有表都使用一个用于序列(ID_Table)的公用表。
TABLE_ID 有两个字段(Common_ID、Table_Name)。
如果我在表中插入任何记录,我必须首先在 Table_ID(Auto-increment, Table_name) 中插入一条记录,然后在我的其他表中使用该自动增量值。
例如,我想插入具有字段 ID(Common_ID)、Product_Name、Product_ID(Auto Increment) 的 Table_Products
我想做这样的事情:
INSERT INTO TABLE_ID (Table_NAME), Values (Table_Products)
获取插入的 ID 并在 Table_Products 中使用它:
INSERT INTO Table_Products (ID, Product_Name, Product_ID(Auto Increment)
VALUES (ID from TABLE_ID, SomeProduct, Increment)