$sql = "SELECT count(sd_2foot) as total,(sd_2foot) as numbers FROM table_name group by sd_2foot having total>1 order by total desc";
$query = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($query);
select numb, sum(ct) as count_ct from(
SELECT top as numb, count(top) as ct FROM tb group by top
union all
SELECT foot, count(foot) FROM tb group by foot
) as tmp group by numb
having sum(ct)>1
select numb, sum(ct) as count_ct from(SELECT top as numb, count(sd_2top) as ct FROM share_detail group by top union all SELECT foot, count(sd_2foot) FROM share_detail group by foot) as tmp group by numb
having sum(ct)>1
select numb, sum(ct) as count_ct from(SELECT sd_2top as numb, count(sd_2top) as ct FROM share_detail group by sd_2top union all SELECT sd_2foot, count(sd_2foot) FROM share_detail group by sd_2foot) as tmp group by numb
having sum(ct)>1