Home > Backend Development > PHP Tutorial > 请问一个mysql查询有关问题,送上100分

请问一个mysql查询有关问题,送上100分

WBOY
Release: 2016-06-13 11:42:35
Original
1109 people have browsed it

请教一个mysql查询问题,送上100分

本帖最后由 SHANDIANDIAN 于 2013-12-12 12:15:27 编辑 表A                表B
uid  mid cash          uid   mid cash   number
1     1   100           1     1   101    100
2     2   105           2     1   100    100
3     3   98            3     2   105    200
4     4   55            4     2   105    300
5     5   60            5     3   60     300
6     6   70            6     3   98     300

uid 是自动增长字段  mid和cash 是关联字段

我想统计出 表B的求和数量就和下面这样,没匹配到表A就显示0,匹配通过mid和cash 两字段。请问SQL该怎么写?? 以表A为基础表
结果表
uid mid   cash  number
1    1     100  100
2    2     105  500
3    3     98   300
4    4     55    0
5    5     60    0
6    6     70    0
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template