| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 836 人关注过本帖
标题:请大家看看我的语句有什么问题[未解决]?
取消只看楼主 加入收藏
关小彤
Rank: 1
等 级:新手上路
帖 子:114
专家分:0
注 册:2006-12-7
收藏
 问题点数:0 回复次数:5 
请大家看看我的语句有什么问题[未解决]?
select a.name,id_card,b.sname,sfzh,a.bknbcode_id,b.leibie into shuju from no07 a , zuihoujieguo b
where a.name=b.sname
and len(b.sfzh)=15 and len(a.id_card)=15 and a.id_card=b.sfzh and a.bknbcode_id=b.leibie
union
select a.name,id_card,b.sname,sfzh,a.bknbcode_id,b.leibie from forums_ksbm a ,zuihoujieguo b
where a.name=b.sname
and left(b.sfzh,6)=left(a.id_card,6)
and len(b.sfzh)=15 and len(a.id_card)=18
and substring(a.id_card,9,6)=substring(b.sfzh,7,6) and a.bknbcode_id=b.leibie
union
select a.name,id_card,b.sname,sfzh,a.bknbcode_id,b.leibie from forums_ksbm a , zuihoujieguo b
where a.name=b.sname
and len(b.sfzh)=18 and len(a.id_card)=18 and a.id_card=b.sfzh and a.bknbcode_id=b.leibie
union
select a.name,id_card,b.sname,sfzh,a.bknbcode_id,b.leibie from forums_ksbm a , zuihoujieguo b
where a.name=b.sname

and left(b.sfzh,6)=left(a.id_card,6)
and len(a.id_card)=15 and len(b.sfzh)=18
and substring(b.sfzh,9,6)=substring(a.id_card,7,6) and a.bknbcode_id=b.leibie


这个语句中查出shuju中有749条记录
然后
select * from shuju a, no07 b where a.name=no07.name and a.id_card =b.id_card
查出的纪录条数是401条


怎么会有这种情况呢?
为什么不是749条呢?

谢谢 :)

[此贴子已经被作者于2007-5-14 17:12:28编辑过]

搜索更多相关主题的帖子: 语句 
2007-05-14 11:48
关小彤
Rank: 1
等 级:新手上路
帖 子:114
专家分:0
注 册:2006-12-7
收藏
得分:0 

不是,我想说的是第一个语句中选出的不是no07中的id_card吗?为什么会有不在no07表中的数据呢


2007-05-14 13:21
关小彤
Rank: 1
等 级:新手上路
帖 子:114
专家分:0
注 册:2006-12-7
收藏
得分:0 
请大家帮帮忙,我都晕了。而且我刚才
用select a.id_card,b.sfzh from no07 a,zuihoujieguo b where a.id_card=b.sfzh and a.bknbcode_id=b.leibie and a.name=b.sname
查出的记录条数竟然是1358
怎么会比上面查出的多呢

2007-05-14 13:40
关小彤
Rank: 1
等 级:新手上路
帖 子:114
专家分:0
注 册:2006-12-7
收藏
得分:0 
没人回答吗?谢谢

2007-05-14 14:05
关小彤
Rank: 1
等 级:新手上路
帖 子:114
专家分:0
注 册:2006-12-7
收藏
得分:0 
基本情况是这样的:两个表中都有身份证号,但是可能存在15位18位的情况,例如:一个人在no07中是15位的,但在另外一个表中是18位的
我想查出两个表中同一个人的信息

2007-05-14 15:44
关小彤
Rank: 1
等 级:新手上路
帖 子:114
专家分:0
注 册:2006-12-7
收藏
得分:0 
第一条语句的结果插入到一个表中时,有11条记录是重复的。奇怪

2007-05-17 11:56
快速回复:请大家看看我的语句有什么问题[未解决]?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027293 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved