我有一个下面的结构表
session
-----
Id
name
Active
我有另一个带有第一个外键的表
DocsMaster
------
Id
SessionId [freign key with session table]
Name
Description
我想编写一个sql补丁来向DocsMaster
表插入一些默认值,我写下面的语句
INSERT INTO `DocsMaster` (SessionId, Name, Description)
VALUES (1,'Registration Certificate',' Scanned copy of reg certificate');
INSERT INTO `DocsMaster` (SessionId, Name, Description)
VALUES (1,'Attestation Certificate',' Scanned copy of certificate');
INSERT INTO `DocsMaster` (SessionId, Name, Description)
VALUES (1,'Safety Certificate',' Scanned copy of certificate');
INSERT INTO `DocsMaster` (SessionId, Name, Description)
VALUES (1,'additional Certificate',' Scanned copy of certificate');
我可以为sessionId
SELECT Id
FROM session
WHERE Active = 1;
并将此id用于insert语句? [或多或少类似于t-SQL]