Home > Database > Mysql Tutorial > mysql---union和左连接的两倒面试题_MySQL

mysql---union和左连接的两倒面试题_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:08:33
Original
2022 people have browsed it

第一道:


思路:无非是将hid与gid与t表中的tname关联起来。实质上是三表关联(m,t,t)

先将hid与tname关联起来,运用左连接


再将结果集与t表中的tname关联起来,使得gid与tname关联起来


再限定时间范围就可以得出最终结果



第二道:



思路:题目的要求是将相同id的值进行求和

我们可以先union all一下


再利用sum函数分组求和


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