November 11th, 2013, 05:53 AM
Mysql counting number of occurrence rows different tables for same user
i have 2 different tables which user_id as common field.
how to write query to count total occurrence of each user in both tables.
say for example. there are 2 & 3 records for a user in two tables respectively. i need user id and total records (i.e) 5
November 11th, 2013, 06:21 AM
, SUM(subtotal) AS total
FROM ( SELECT userid
, COUNT(*) AS subtotal
BY userid ) AS u