数据库sql语句_关于数据库SQL语句的编写
问题补充:
有两张表,user表和reqlet信件表
user表(userid,username,...)
reqlet(reqid,reqtitle,reqcontent,userid)
user表和信件表是一对多关系
要求统计user表中每个用户收到个数个数
按照 userid username sum(信件个数)的方式显示出来
尽量使用通用sql语句
补充:使用一条语句最佳答案
若你的信件个数是就是reqlet的记录条数
你可以试试以下语句
select a.userid,a.username,count(*) as total
from
user a, reqlrt b
where a.userid=b.userid
group by a.userid,a.username
最佳答案由网友 whoami1978 提供
其他回答
暂无其它回答!