PostgresSql 多表关联删除语句

最近用PostgresSql数据库进行多表关联删除的操作,在写sql语句的时候遇到了问题:

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

上面两种写法操作后提示报错,下面是PostgresSql数据库对多表关联操作的正确用法,多张表之间用USING连接:

DELETE FROM student s USING classroom c WHERE s.cid = c.id AND s.sid = 1
发布了69 篇原创文章 · 获赞 253 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_41595700/article/details/94985611