SQL 更新:您无法指定目标表“nilai_mhs”;用于 FROM 子句中的更新“
我有这样的查询:
UPDATE nilai_mhs
SET status_nilai = 3
where
id_kode_mk =
(SELECT e.id_kode_mk
FROM nilai_mhs c, tbl_mhs d,master_mk e,tbl_mk_pertahun f
WHERE
c.nim = d.nim
AND
c.id_kode_mk = e.id_kode_mk
AND
e.id_kode_mk = f.id_kode_mk
AND
c.nim = '20081001010125'
AND
c.status_nilai =2
AND
sem_ganjil_genap = 'ganjil')
但结果显示错误:
您无法在 FROM 子句中指定要更新的目标表“nilai_mhs”
有人可以帮助我吗?
I have query like:
UPDATE nilai_mhs
SET status_nilai = 3
where
id_kode_mk =
(SELECT e.id_kode_mk
FROM nilai_mhs c, tbl_mhs d,master_mk e,tbl_mk_pertahun f
WHERE
c.nim = d.nim
AND
c.id_kode_mk = e.id_kode_mk
AND
e.id_kode_mk = f.id_kode_mk
AND
c.nim = '20081001010125'
AND
c.status_nilai =2
AND
sem_ganjil_genap = 'ganjil')
but the result displays error:
You can't specify target table 'nilai_mhs' for update in FROM clause
Can anybody help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需直接更新表而不使用子查询
如果您需要执行子查询(例如对结果进行分组),则需要加入子查询:
Just update the table directly without a subquery
If you need to perform a subquery (for example you are groupping results) you need to join the subquery instead: