我正在尝试从TherapistRates
表中向我的serviceLink
表中插入多行。我需要在每一行上加therapistID
。但是,SQL不允许我在插入多行时添加值。我该如何解决这个问题?
这是我的问题:
INSERT INTO TherapistRates (therapistID, serviceType)
VALUES (@therapistID, (SELECT (serviceID) FROM serviceLink WHERE TherapistTypeID = @therapistID)
答案 0 :(得分:2)
为什么不:
insert into TheRapistRates (TherapistID, serviceType)
select TherapistTypeID , serviceID
from serviceLink
where TherapistTypeID = @TherapistID
NEW VERSION(来自对其他答案的评论)
insert into TheRapistRates (TherapistID, serviceType)
select @TherapistID, serviceID
from serviceLink
where TherapistTypeID = @TherapistTypeID
答案 1 :(得分:0)
这是你要找的吗?
Insert TherapistRates
(therapistID, serviceType)
Select @TherapistId, ServiceId
From ServiceLink
Where TherapistTypeID = @TherapistTypeID