Re: Help with query (or subquery?)

2011-08-09 Thread John Andersen
>From what I understand of your issue, you just need 4 different counts for each user, who has sent invitations. So using a little of my experience with SQL, I would think something like this could be a starting point for you. [code] SELECT usr.id, usr.login_name, COUNT(rem.id) AS total_invitation

Re: Help with query (or subquery?)

2011-08-09 Thread John Hardy
You need to look into cross-tablualtion / Pivot Tables. There is a good article on mysql.com http://dev.mysql.com/tech-resources/articles/wizard/print_version.html On Aug 9, 2011, at 8:04 AM, Anna P wrote: > Hello. > > It's maybe not such a CakePHP question, but rather regarding a rather > co

Help with query (or subquery?)

2011-08-09 Thread Anna P
Hello. It's maybe not such a CakePHP question, but rather regarding a rather complex (for me) SQL query. I have a table storing e-mail addresses to which has been sent an invite to a website: CREATE TABLE IF NOT EXISTS `recomm_emails` ( `id` mediumint(7) unsigned NOT NULL AUTO_INCREMENT, `us