dqv84329 2016-12-07 16:56
浏览 10
已采纳

计算mysql中两个表之间的公共行

so here's my question...

Hi have two tables in mysql, called go_H and go_J, both looking like this:

go_H

+---------------+------------+
| gene          | GoCode     |
+---------------+------------+
| DNAJC25-GNG10 | GO:0004871 |
| DNAJC25-GNG10 | GO:0005834 |
| DNAJC25-GNG10 | GO:0007186 |
| LOC100509620  | GO:0005215 |
| LOC100509620  | GO:0006810 |
| LOC100509620  | GO:0016021 |
| PPIAL4E       | GO:0000413 |
| PPIAL4E       | GO:0003755 |
| PPIAL4E       | GO:0005737 |
| PPIAL4E       | GO:0006457 |
| LOC105371242  | GO:0000413 |
+----------------------------+

go_J

+------------+
| GoCode     |
+------------+
| GO:0007254 |
| GO:0007256 |
| GO:0007257 |
| GO:0042655 |
| GO:0043506 |
| GO:0043507 |
| GO:0043508 |
| GO:0046328 |
| GO:0046329 |
| GO:0046330 |
+------------+

Basically what I want to achieve is to see what GoCode values from go_J appear in GoCode from Go_H, and count them, so as I get a total number o GO ids that are present in both tables.

I have come to select go_H.GoCode and go_J.GoCode, but I don't know how to compare them to find common rows and then count them...

Any help?

  • 写回答

4条回答 默认 最新

  • dongming6201 2016-12-07 17:00
    关注

    Hope this helps.

    select count(*) from go_J j join  go_H h on h.GoCode=j.GoCode;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿