Table: immunization
id vac_id vaccine_id
1 5 0
2 5 0
3 3 0
4 4 0
5 4 0
Table: vaccine
id vac_id
8 1
9 2
10 3
11 4
12 5
我有两个表,现在我想通过匹配疫苗将疫苗表的id设置到免疫表的vaccine_id中.vac_id = immunization.vac_id
要做到这一点我使用了查询,但收到错误1064
UPDATE immunization
SET immunization.vaccine_id = vaccine.id
FROM vaccine,immunization
WHERE vaccine.vac_id = immunization.vac_id
答案 0 :(得分:1)
UPDATE immunization i
join vaccine v
on i.vac_id=v.vac_id
SET i.vaccine_id = v.id
设置到最后