I have a query result like this https://i.sstatic.net/sDuIj.png
EDIT: Here is the actual table http://pastebin.com/TZCGHKdt
SECOND EDIT: http://sqlfiddle.com/#!2/49bae/1
If u see the result in the SQLFIDDLE link, it shows duplicate entries in ID column. For example the value 26 in the ID Column has a total of 4 values, the query shows them broken up into 3 and 1. I want them joined.
Here is the insert query for the table that i'm using
INSERT INTO `capture_captive` (`capture_id_1`, `capture_id_2`, `capture_id_3`, `capture_id_4`, `capture_id_5`)
VALUES
(23, 32, 0, 0, 0),
(26, 25, 24, 0, 15),
(26, 32, 0, 0, 0),
(0, 0, 0, 0, 0),
(26, 26, 0, 0, 0),
(32, 32, 0, 0, 0);
The query that i'm using is
select id, num from
(select `capture_id_1` id, (COUNT(capture_id_1)) num from capture_captive where capture_id_1<>0 group by capture_id_1
UNION
select `capture_id_2`, (COUNT(capture_id_2)) num from capture_captive where capture_id_2<>0 group by capture_id_2
UNION
select `capture_id_3`, (COUNT(capture_id_3)) num from capture_captive where capture_id_3<>0 group by capture_id_3
UNION
select `capture_id_4`, (COUNT(capture_id_4)) num from capture_captive where capture_id_4<>0 group by capture_id_4
UNION
select `capture_id_5`, (COUNT(capture_id_5)) num from capture_captive where capture_id_5<>0 group by capture_id_5 ) as E
where id<>0
order by id;
I want to show the total number of id, against their ids.
Thanks in advance.