PostgreSQL 多表关联删除
用PostgreSQL数据库删除某个表数据 student,需要关联多个表(如classroom)作为条件,以下语句走不通:
delete s.* from student s,classroom c where s.cid = c.id and s.sid = 1
delete from student s,classroom c where s.cid = c.id and s.sid = 1
上面两种写法操作后提示报错,下面是PostgreSQL数据库对多表关联删除的正确用法,多张表之间用using连接:
delete FROM student s using classroom c where s.cid = c.id and s.sid = 1
还没有评论,来说两句吧...