像INSERT查询MYSQL中的SELECT一样的T-SQL

时间:2015-10-18 06:53:16

标签: mysql

我有一个下面的结构表

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

创建一个t-SQL语句
SELECT Id 
FROM session 
WHERE Active = 1; 

并将此id用于insert语句? [或多或少类似于t-SQL]

0 个答案:

没有答案