焦焦急急切切盼盼!求助,两表条件删除?
表1 表2
lsh kdrq lsh zd1
A1001 2006-01-23 A1001 xxxx
A1003 2006-10-12 A1003 xxxx
B20034 2007-02-25 B20034 xxxx
b5632 2006-08-10 b5632 xxxx
..... 20........ ......
表1 与 表2 的 相关联的,现在要删除(表2)中(lsh)在2007年以前的数据,但表2没有日期显示.
------解决方案--------------------delete a from 表2 a,表1 b where a.lsh =b.lsh and b.kdrq < '2007-01-01 '
------解决方案--------------------delete 表2
from 表1 a inner join 表2 b on a.lsh =blh
where a.kdrq < '2007-01-01 '
------解决方案----------------------try
delect from table2 where lsh in(select lsh from table1 where kdrq < '2007/01/01 ')
------解决方案--------------------delete from 表2
where lsh in
(
select b.lsh from 表1 a inner join 表2 b on a.lsh = b.lsh and year(a.kdrq) = 2007
)