Mysql inq-查询多个表的结果

Mysql inq-查询多个表的结果,mysql,count,Mysql,Count,我正在编写一个问题跟踪脚本,查看mysql语句,我能够获得所有优先级问题的计数,但无法获得状态的计数 如何使用下面的mysql语句检索状态计数 tbl_status index status 1 open 2 closed 3 pending tbl_priority index priority 1 low 2 medium 3 high tbl_inci

我正在编写一个问题跟踪脚本,查看mysql语句,我能够获得所有优先级问题的计数,但无法获得状态的计数

如何使用下面的mysql语句检索状态计数

tbl_status
index    status
 1         open
 2         closed
 3         pending

tbl_priority
index      priority
1           low
2           medium
3             high


tbl_incident
incident  priority   status
adfadf        1          2
adfsdf        2          2
adfadf        1          1
adfadf        3          2
adfasdf       1          3
我能够将优先级分组如下(工作):

喜欢与状态相同的结果,但它不起作用。也许一句话要求太多了

open 1
closed 3
high 1
也许一句话要求太多了

open 1
closed 3
high 1
是的,试着为每个问题分开陈述。依我看,这样会更有效率

对于状态:

select tbl_status.status, count(*)
from tbl_incident 
    inner join tbl_status on tbl_status.index = tbl_incident.status
group by tbl_status.status;
至于优先事项:

select tbl_priority.priority, count(*)
from tbl_incident 
    inner join tbl_priority on tbl_priority.index = tbl_incident.priority
group by tbl_priority.priority;
select tbl_priority.priority, count(*)
from tbl_incident 
    inner join tbl_priority on tbl_priority.index = tbl_incident.priority
group by tbl_priority.priority;