delete from b
where IID IN
(
Select B.IID
from A,B
where A.NID=523 and A.NID=B.NID and A.Ph_no<>B.Ph_no
)
不知道是不是要删除这些东西,给的例子太模糊了。
where IID IN
(
Select B.IID
from A,B
where A.NID=523 and A.NID=B.NID and A.Ph_no<>B.Ph_no
)
不知道是不是要删除这些东西,给的例子太模糊了。
表一:A
IID NID Ph_no
7099 523 555
表二:B
IID NID A_IID Ph_no
19485 523 7099 555
19484 523 7099 583 用发下方式如何删除这条记录
IID NID A_IID Ph_no
19484 523 7099 583 delete from b
where NID = 523 (只能给出这个条件)
and (A.ph_no=B.ph_no)
where B.NID = 523 and (A.ph_no=B.ph_no)
where NID = 523 (只能给出这个条件)
and ph_no not in (select a.ph_no from a,b where a.nid=b.nid )
( Select b.IID from A,B
where and A.NID=B.NID and A.Ph_no=B.Ph_no
)
条件是这样的 A.IID = b.NID and a.NID = b.A_IID and a.Ph_no = b.Ph_no
表B中不满足的记录删除
where b.nid=523 and (b.ph_no <> (select a.ph_no form a where a.iid=b.a_iid))