Reputation: 2696
I am using this statement to count the numbers of occurrences of a particular ID
SELECT cms_id, COUNT( * ) AS Number
FROM website
GROUP BY cms_id
ORDER BY `website`.`cms_id` ASC
LIMIT 0 , 30
However in another table I have the title name for each of the cms_id
cms_id cms_name
1 wordpress
How can I then retrieve the name form the other table and show this instead of the cms_ID
Upvotes: 0
Views: 62
Reputation: 263683
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
To further gain more knowledge about joins, kindly visit the link below:
Upvotes: 2