duankang8114 2017-07-18 05:03
浏览 56
已采纳

在mysql查询中加入数据重复之后

table :First
..............................................................................
id | ros | table | column | stool | date | places|
..............................................................................
1   12  5   6   a   2017-07-17  goa  |
2   12  5   6   b   2017-07-17  delhi|
..............................................................................


table :second

..........................................................................
id  | ros | name | email | phone | stos|address |date |
....................................................................................................
5      12    and   and@her.com  394924673464    6  fddsfds  2017-07-03 |
6      12    her     her@and.com    84838593894     6  fdafdfd  2017-07-04  |
....................................................................................................


Query like I am Using:
SELECT `p`.* FROM `first` `p` LEFT JOIN `second` as `st` ON `st`.`ros`=`p`.`ros` ORDER BY `id` DESC LIMIT 10;

My question is why it returns 4 rows instead of just 2? its resturning 4 value without having in the table should i need to use distinct or group by for that ??

  • 写回答

4条回答 默认 最新

  • duan0531 2017-07-18 05:05
    关注

    Try this query :

    SELECT p.* FROM first as p LEFT JOIN second as st ON st.site_id=p.site_id group by p.id ORDER BY p.id DESC LIMIT 10;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作