我有一个company cid ,这是一个 int类型 出现在两个表格中
companydet
opprt
我遇到一个问题,我试图根据 cname comapny名称 companydet 检索 cid 在重新尝试存储此ID后, 类型
我试过这段代码
select c.cid
from companydet c
where cname='google'
and insert into opprt( cid,oppdetails,oppfp,oppap,oppcd,oppd )
values('@c.cid','abc','','','','')
但它不起作用请帮助我并解释我怎么能这样做?
答案 0 :(得分:2)
您可以使用throw new BeforeValidException(
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
);
:
insert...select
答案 1 :(得分:0)
我想你想要insert into opprt( cid,oppdetails,oppfp,oppap,oppcd,oppd )
select cid,'abc','','','',''
from companydet
where cname='google'
:
insert . . . select
答案 2 :(得分:0)
使用另一个表
插入表中insert into opprt( cid,oppdetails,oppfp,oppap,oppcd,oppd )
Select Columnname,Columnname1,Colummname2,Columnname3,...etc from companydet
where cname='google'
使用静态值插入值
insert into opprt( cid,oppdetails,oppfp,oppap,oppcd,oppd )
Values(cid,'abc','','','','')
答案 3 :(得分:0)
你需要使用insert into .... select语句。 你还发现在opprt中的cid是int,而在companydet中的cid是varchar,所以你需要将cat cid转换为int。
请关注我的代码。
insert into opprt( cid,oppdetails,oppfp,oppap,oppcd,oppd )
select CAST(cid as int),'abc','','','',''
from companydet
where cname='google'
谢谢。
答案 4 :(得分:0)
您可能也想尝试一下:
declare @d_cid int
select @d_cid = c.cid from companydet c where cname='google'
insert into opprt( cid,oppdetails,oppfp,oppap,oppcd,oppd )
values(@d_cid,'abc','','','','')