请教这样子的多表查询语句怎么写呢

WBOY
Release: 2016-06-13 12:22:49
Original
898 people have browsed it

请问这样子的多表查询语句如何写呢

本帖最后由 taodala 于 2015-06-30 18:26:38 编辑 一个分类表cate         一个文章表 article

我想在一个分类页中.列出cate表中所有分类  

同时把此表中的每个分类在article表中的文章数量,查询出来.怎么写呢,谢谢

通过cateid 关联

------解决思路----------------------
SELECT a.*,COUNT(b.cate_id) FROM `cate` a LEFT JOIN `article` b ON a.id=b.cate_id GROUP BY b.cate_id    LIMIT 10
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!