SQL语句

A表:用户 用户ID(主键),姓名,手机号码,固定电话

B表:事件 事件号(主键),用户ID,事件主题,事件描述

 

要删除手机号码,固定电话都为空的,且没有产生事件的用户。

select * from A表 where 手机号码 is null and 固定电话 is null and 用户ID not in ( select distinct 用户ID from B 表)

结果查询出来是空,用数据来判断,数据不会为空。哈哈。。

一度怀疑。。。。。。

 

最后查询代码修改为=

select * from A表 where 手机号码 is null and 固定电话 is null and 用户ID not in ( select distinct 用户ID from B 表 where b表.用户ID>0 ) 其实这个条件其实是没有太大意义的。

 

最后删除数据 delete

 

over........

posted @ 2011-10-13 16:52  海莹  阅读(128)  评论(0编辑  收藏  举报