您的位置:首页技术文章
文章详情页

mysql - 求一个sql语句,比较简单。

【字号: 日期:2022-06-16 11:10:11浏览:43作者:猪猪

问题描述

问题解答

回答1:

select j.*, (select count(*) from submitjobs s where j.id=s.jobid) from jobs j回答2:

mysql 为例:select a.*,count(b.userid)sbtotal from jobs a left join sumbmitjobs b on b.jobid=a.id gourp by b.jobid order b.userid

oracle 差不多 只是不能那样分组需要先分组sumbmitjobs 统计好然后作为子查询回答3:

SELECT COUNT(DISTINCT column(jobName)) FROM jobs LEFT JOIN submitjobs ON jobs.jobName=submitjobs.jobName

回答4:

select b.name, a.cnt from jobs b left join (select jobid, count(userid) as cntfrom submitjobsgroup by jobid) aon b.id = a.jobid回答5:

没测试...

SELECT j.id, j.name, COUNT(sj.jobid) AS countFROM `submitjobs`AS sjJOIN `jobs`AS jWHERE sj.jobid = j.idGROUP BY sj.jobid回答6:

其实最简单

select 想要的字段 from 表1,表2 ...表N

此种写法不管有多少表都能连起来