insert ta (id)select id from tb where name='...' ???
insert tableName(classID) select classid from tableClass where classname='类名称'
declare @id nvarchar(20) select @id=id from table where name='名称' insert into table(id) values(@id)这是sql的,代码里也可以做类似操作
insert into 插入表名 (列名1,列名2,外健字段名) select 值1,值2,id from 大类表名 where name='大类名称'
insert into info (cName ,cCreateTime,cAuthor, hits,cCreateContent, tID) values ('ss','ss', 'ss', 23, 'ss',(select tID from BigClass where tName='经典讲座')) 我是这样写的 他说 在此上下文中不允许使用子查询。只允许使用标量表达式。
insert into info (cName ,cCreateTime,cAuthor, hits,cCreateContent, tID) select 'ss','ss', 'ss', 23, 'ss',tID from BigClass where tName='经典讲座'
insert into info (cName ,cCreateTime,cAuthor, hits,cCreateContent, tID) select 'ss','ss', 'ss', 23, 'ss', tID from BigClass where tName='经典讲座' 有values 就不要用select 用select 就不要values
???
select classid
from tableClass
where classname='类名称'
select @id=id from table where name='名称'
insert into table(id) values(@id)这是sql的,代码里也可以做类似操作
select 值1,值2,id from 大类表名 where name='大类名称'
from BigClass where tName='经典讲座'
select 'ss','ss', 'ss', 23, 'ss', tID from BigClass where tName='经典讲座' 有values 就不要用select
用select 就不要values