Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用此语句来计算特定 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
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
要进一步了解有关联接的更多信息,请访问以下链接: