I already know i can do outer join in MySQL using union.
I also check this one.
Full Outer Join in MySQL
But i want to do something like this and I don't know how can I achieve this using union.
I have db table user_count as follow.
+-------------+-----------+---------+-------+
| meb_id      | left_id   |right_id |active |    
+-------------+-----------+---------+-------+
| 1001        | (NULL)    | (NULL)  |  1    | 
| 1002        | 1001      | 0       |  0    | 
| 1003        | 0         | 1001    |  0    |
| 1004        | 1001      | 0       |  0    |
| 1004        | 1002      | 0       |  0    |
+-------------+-----------+---------+-------+
I have queries as follow.
    SELECT left_id, COUNT(left_id) AS left_count FROM `user_count` GROUP BY left_id 
    SELECT right_id, COUNT(right_id) AS right_count FROM `user_count` GROUP BY right_id;
SELECT left_id AS meb_id, COUNT(left_id) AS active_left_count FROM `user_count` WHERE active = 1 GROUP BY left_id;
SELECT right_id AS meb_id, COUNT(right_id) AS active_right_count FROM `user_count` WHERE active = 1 GROUP BY right_id;
I want to preform outer join or union so my result will be like this
+-------------+-----------+------------+------------+--------------+
| meb_id      |left_count |right_count |active_left |active_right  | 
+-------------+-----------+------------+------------+--------------+
| (NULL)      | 0         | 0          |  0         | 0            |
| 0           | 1         | 3          |  0         | 0            |
| 1001        | 2         | 1          |  0         | 0            | 
| 1002        | 1         | 0          |  0         | 0            |
| 1003        | 0         | 0          |  0         | 0            | 
+-------------+-----------+------------+------------+--------------+
How can i do this. Any help greatly appreciated.
 
     
    