this solution worked ok
SELECT user_id, COUNT(user_id)
FROM
(
SELECT user_id
FROM login_info_1
UNION ALL
SELECT user_id
FROM login_info_2
) AS lgin_info
GROUP BY user_id;
me think the theory pretty much works the same way
thanks
select a.user_id, count(b.user_id) from login_info_1 a join login_info_2 b on a.user_id=b.user_id group by a.user_id
On Fri, Jul 29, 2011 at 12:44 PM, The sherminator <steve.kim41@gmail.com> wrote:
_______________________________________________I have two table login_info_1,login_info_2 which has a column user_id in each table
select user_id,count(user_id) as cnt from login_info_1 group by user_id;
which gives me result like this
user_id cnt
101 4
102 5
103 1
107 7
same for the second table
select user_id,count(user_id) as cnt2 from login_info_2 group by user_id;
user_id cnt
101 3
102 2
103 2
107 1
I want to combine these two tables and the results should look like this
user_id cnt
101 7
102 7
103 3
107 2
Database: MYSQL
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
--
Regards,
Peter Karunyu
-------------------
Web Performance Evangelist
Make your website and web app faster.
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke