Suppose I have a MySQL table with just 2 columns:
id
invited_by_id
and I want to know for
each id how many times it appears in invited_by_id column.
How to make this using only one query?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A simple
GROUP BYon theinvited_by_idcolumn is all you need, since it holds the same id values as theidcolumn: