Home > Database > Mysql Tutorial > body text

sql查询统计,根据新闻类别ID统计,没有数据显示0

WBOY
Release: 2016-06-07 17:40:24
Original
1468 people have browsed it

有两张表,新闻信息表MessageInfo和新闻类别表MessageType。表结构如下: 然后需要实现下面这种查询结果: 这个是我面试时遇到的,上面的新闻类型是乱写的。当时没有做出来,然后回来又研究了下。 刚开始是这么想的,新闻类型表MessageType左连接left join新

有两张表,新闻信息表MessageInfo和新闻类别表MessageType。表结构如下:

然后需要实现下面这种查询结果:

这个是我面试时遇到的,上面的新闻类型是乱写的。当时没有做出来,网站空间,然后回来又研究了下。

刚开始是这么想的,网站空间,新闻类型表MessageType左连接left join新闻信息表MessageInfo,筛除那些新闻ID为空的,然后根据新闻类型名直接分组统计。

,MessageType left join MessageInfo MessageName ,网站空间

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!