JobPost_Skill
JobPost_Skill_ID JobPost_ID Skill_ID
----------- ----------- -----------
1 1 1
2 1 2
3 1 3
4 2 3
5 2 5
这是我的第三个表,其中JobPost_ID,Skill_ID是外键 现在我想更新查询,它只会更新JobPost_ID = 1的两行Skill_ID。
这意味着我的输出应该是
JobPost_Skill_ID JobPost_ID Skill_ID
----------- ----------- -----------
1 1 4
2 1 5
3 1 3
4 2 3
5 2 5
答案 0 :(得分:0)
您可以使用以下查询进行更新
updete JobPost_Skill
set Skill_ID =New Skill_ID
where JobPost_ID=JobPost_ID
and Skill_ID = oldSkill_ID
注意:替换
JobPost_ID您需要更新的职位发布ID
技能ID的新Skill_ID新值
oldSkill_ID技能ID的旧值
<强>即强>
updete JobPost_Skill set Skill_ID = 4 where JobPost_ID=1 and Skill_ID = 1;
updete JobPost_Skill set Skill_ID = 5 where JobPost_ID=1 and Skill_ID = 2,