select *,(
select count(*) from table2 where 1
and table1.idx.code=table2.sidx_code //상위에 해당하는내용과 서브에 해당하는 내용을 일치시켜서 갯수호출함
group by sidx_code
) as count //count로 카운트 갯수를 표기함
from table1
where 1
order by count //전체 적인 지리문을 정렬함
첫번째 테이블 table1
두번째 테이블 table2
table1.idx_code값은
table2.sidx_code값과 동일함 sidx_code값은 여러게 존제함