select score from student,sc where score in (select score from student,sc where c=1 and student.s=sc.s);
36 rows in set (0.00 sec)
select score from sc;
21 rows in set (0.00 sec)
只有sc表里面有score字段,不明白为什么加点东西进去,就多了一些重复的记录了。
| score | | score |
+-------+
| 56 |
| 79 |
| 91 |
| 56 |
| 46 |
| 35 |
| 56 |
| 79 |
| 91 |
| 56 |
| 46 |
| 35 |
| 56 |
| 79 |
| 91 |
| 56 |
| 46 |
| 35 |
| 56 |
| 79 |
| 91 |
| 56 |
| 46 |
| 35 |
| 56 |
| 79 |
| 91 |
| 56 |
| 46 |
| 35 |
| 56 |
| 79 |
| 91 |
| 56 |
| 46 |
| 35 |
+-------+
+-------+
| 56 |
| 78 |
| 67 |
| 58 |
| 79 |
| 81 |
| 92 |
| 68 |
| 91 |
| 47 |
| 88 |
| 56 |
| 88 |
| 90 |
| 93 |
| 46 |
| 78 |
| 53 |
| 35 |
| 68 |
| 71 |
+-------+
mysql查询结果错误问题--增加了一些重复的记录
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 蜗牛_snail 2017-09-02 00:29关注
select score from student,sc where score in (select score from student,sc where c=1 and student.s=sc.s);
这个sql就不正确。。。。
看最外层的sql“select score from student,sc where score in ...” student,sc表没有通过字段关联上,但你只查询了score一个字段,所以你只觉得是有一条重复的记录。
你执行“select * from student,sc where score in ...”这条sql就可以看出问题来了。解决 无用评论 打赏 举报
悬赏问题
- ¥20 delta降尺度方法,未来数据怎么降尺度
- ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
- ¥15 高德地图点聚合中Marker的位置无法实时更新
- ¥15 DIFY API Endpoint 问题。
- ¥20 sub地址DHCP问题
- ¥15 delta降尺度计算的一些细节,有偿
- ¥15 Arduino红外遥控代码有问题
- ¥15 数值计算离散正交多项式
- ¥30 数值计算均差系数编程
- ¥15 redis-full-check比较 两个集群的数据出错