|
select xs.xh,xs.xm,xs.zy
from tb_xs xs,tb_xk xk,tb_kc kc
where xs.xh=xk.xh and xk.kch=kc.kch and kc.kcm='物理'
delete xk
from tb_xk xk,tb_kc kc
where xk.kch=kc.kch and kc.kcm='数学'
select distinct kc.kch,kc.kcm
from tb_xk xk,tb_kc kc,tb_xs xs
where xs.xh=xk.xh and xk.kch<>kc.kch
CREATE PROCEDURE my_proc --在XS表和XK表间级联删除
@name varchar(8)
AS
delete xs
from tb_xk xk, tb_xs xs
where xs.xh=xk.xh and xs.xm=@name
EXECUTE my_proc 'name'
|