INSERT INTO dbo.VehiclesCategories (VehicleId, CategoryId)
VALUES (t1.ID , t2.ID)
SELECT t1.ID, t2.ID
FROM dbo.Vehicle t1
inner JOIN dbo.VehicleCategory t2 ON t1.Category = t2.Name
在上面的SQL中,我想将两个值插入到M:M连接表中。 SELECT语句工作正常,我得到了期望的结果。 INSERT语句抛出以下错误:我该如何解决“在这种情况下名称'X'是不允许的?”?
Msg 128, Level 15, State 1, Line 2
The name "t1.ID" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
如何将两个值(t1.ID和t2.ID)插入表中?
猜测删除我已经成为一个驱动器downvoter伤亡...说明会很好。 – DenaliHardtail