日期:2014-05-18 浏览次数:20529 次
delete from student where teacherId in (select stuff(select ','+cast(id as varchar) from teacher where status=1),1,1,''))
--不过没看明白什么意思,呵呵 delete from student where teacherId in (select stuff((--少个括号 select ','+cast(id as varchar) from teacher where status=1),1,1,''))
------解决方案--------------------
--按你的想法呢,其实你可以这样写,没必要整这么复杂 delete student where exists (select 1 from teacher where teacher.id=student.teacherId and status=1); --or delete student where teacherId in (select id from teacher where status=1);
------解决方案--------------------
你哪个要拼接成动态的才可以。
------解决方案--------------------
delete from student where teacherId in (select id from teacher where status=1);