Home > Database > Mysql Tutorial > body text

一个SQL语句获得某人参与的帖子及在该帖得分总和

WBOY
Release: 2016-06-07 17:57:06
Original
868 people have browsed it

一个SQL语句获得某人参与的帖子及在该帖得分总和

select a.*,b.SumPoint from Expert_Topic_Index a,(
select TopicID, Sum(Point) as SumPoint from expert_reply_index
where PostUserName = 'ghj1976'
Group by TopicID
Having Sum(Point) > 0
) as b
where a.TopicID = b.TopicID

这里其实就是把一个查询的结果放到新的一个查询中了。

另外 Having 对分组结果进行的查询。
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