0

我正在使用此语句来计算特定 ID 的出现次数

SELECT cms_id, COUNT( * ) AS Number
FROM website
GROUP BY cms_id
ORDER BY  `website`.`cms_id` ASC 
LIMIT 0 , 30

但是在另一个表中,我有每个 cms_id 的标题名称

cms_id cms_name   
1     wordpress

然后我如何从另一个表中检索名称并显示它而不是 cms_ID

4

1 回答 1

2
SELECT  a.cms_id, b.cms_name, COUNT(*) AS Number -- <<== you can remove a.cms_id
FROM    website a
        INNER JOIN anotherTable b
            ON a.cms_id = b.cms_id
GROUP   BY a.cms_id, b.cms_name
ORDER   BY a.cms_id ASC 
LIMIT   0 , 30

要进一步了解有关联接的更多信息,请访问以下链接:

于 2013-05-07T02:46:47.670 回答