Mysql SQL删除错误1064

Mysql SQL删除错误1064,mysql,select,sql-delete,Mysql,Select,Sql Delete,我不知道为什么我的deletesql命令得到了错误号1064。 我的删除sql: delete from nit.grades g where (select id_dep from nit.offers as oo,nit.subjects as s where s.id=oo.id_subject and g.id_offer=oo.id) !=(select id_dep from nit.students as stu where g.id_student=stu.id); 但是这个

我不知道为什么我的deletesql命令得到了错误号1064。 我的删除sql:

delete from nit.grades g where 
(select id_dep from nit.offers as oo,nit.subjects as s where s.id=oo.id_subject and g.id_offer=oo.id)
!=(select id_dep from nit.students as stu where g.id_student=stu.id);
但是这个sql Select和where子句是一样的

select * from nit.grades g where 
(select id_dep from nit.offers as oo,nit.subjects as s where s.id=oo.id_subject and g.id_offer=oo.id)
!=(select id_dep from nit.students as stu where g.id_student=stu.id);
谢谢你的帮助。 错误消息:

用于delete语句的表别名语法错误。 在子查询中,您甚至可以使用目标表,这在MySql中是不允许的。 相反,您应该使用连接。 从您的代码中,我了解到您想要的是:

delete g 
from nit.grades g 
inner join nit.offers oo on g.id_offer = oo.id
inner join nit.subjects s on s.id = oo.id_subject
inner join nit.students st on g.id_student = st.id
where st.id_dep <> s.id_dep

您使两个查询都相同。delete命令在同一个数据库上工作,但在mysql工作台上。请发布完整的错误消息,因为它告诉您mysql在哪里遇到语法错误。这会给我们一个提示。哦,你有1064或1065的错误吗?标题是前者,正文是后者。将oo改为s:“where st.id_dep s.id_dep”
delete g 
from nit.grades g 
inner join (
  <your select query here>
) t
on t.id = g.id