0

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

1 Answer 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

To further gain more knowledge about joins, kindly visit the link below:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.