number1killer 2017-09-01 10:34 采纳率: 0%
浏览 704

mysql查询结果错误问题--增加了一些重复的记录

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 |
+-------+

  • 写回答

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就可以看出问题来了。

    评论

报告相同问题?

悬赏问题

  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)
  • ¥15 如何解决MIPS计算是否溢出
  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
  • ¥15 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件
  • ¥15 visual studio2022中文乱码无法解决
  • ¥15 关于华为5g模块mh5000-31接线问题
  • ¥15 keil L6007U报错