sql 执行 delete 的时候,结合子查询 exists ,怎样支持别名呢?

在做一个数据删除的时候,条件需要用到关联其他表,用到子查询,但是查询的时候使用 别名 没有问题,但是删除就有语法错误,在网上查询后得到了完美解决:

 

--查询出来需要删除的数据
select * from RubricInfo A where exists (
select  * from RubricInfo B where SubjectID = 13 and A.SubjectID=B.SubjectID)

 

-- 删除数据,使用别名的时候
delete A from RubricInfo A where exists (
select  * from RubricInfo B where SubjectID = 13 and A.SubjectID=B.SubjectID)

 

posted @ 2015-12-11 11:00  Young汨  阅读(3651)  评论(0编辑  收藏  举报