database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 25027 게시물 읽기
No. 25027
Tree구조로 select하기..
작성자
노지심
작성일
2006-01-25 15:31
조회수
1,667

안녕하세요

트리구조의 데이터를 select 하는데 지금 아주 문제가 있는 상태로 사용하고 있어서..

문의를 드립니다.

 

아래 보시는 표와 같은 구조와 데이터의 테이블이 있습니다.

지금은 제가 sql을 짜다 실패하고 시간도 급박하고 하여

' order by 경로 ' 로만 select 해버렸습니다.

그렇게 하니 어쟀든 경로가 path를 나타내니 트리형태로가져 올 수는 있었습니다만..

 

메뉴 순서가 적용이 안된느상태로 select가 됩니다.

아래 표는 지금 select 해온 정렬인데요..

 

- 가[2]

- 가1[1]

- 가2[2]

- 나[1]

- 나1[2]

- 나2[1]

이 상태에서 1depth 우선순위는 가=2, 나=1 인 부분을 처리를 해야합니다.

 

[우선순위]라고 했을 때

나2

나1

가1

가2

이렇게 select하길 원합니다...

 

우선순위는 현재 형재노드끼리만 비교해야하는데요

쌩 삽질을 해가며 짠 sql이 있긴한데 동작도 안되고.. 말도 안되는거같아서 -_-; 못올리겠습니다.

 

이걸 sql만으로 정렬하여 select가 가능한지요 조언 및 도움 부탁드립니다.

 

 

 

유일키 부모키 깊이 메뉴순서 이름 경로
693 root 1 4 en /en/
695 693 2 2 assembly /en/assembly/
706 695 3 3 activity /en/assembly/activity/
704 695 3 1 greeting /en/assembly/greeting/
705 695 3 2 member /en/assembly/member/
694 693 2 1 boseong /en/boseong/
703 694 3 4 history /en/boseong/history/
702 694 3 3 location /en/boseong/location/
700 694 3 1 mayor /en/boseong/mayor/
725 700 4 2 career /en/boseong/mayor/career/
724 700 4 1 greeting /en/boseong/mayor/greeting/
701 694 3 2 symbol /en/boseong/symbol/
696 693 2 3 culture /en/culture/
713 696 3 7 event /en/culture/event/
805 713 4 1 dahyang /en/culture/event/dahyang/
808 713 4 4 falk /en/culture/event/falk/
806 713 4 2 miss /en/culture/event/miss/
807 713 4 3 sori /en/culture/event/sori/
711 696 3 5 farm /en/culture/farm/
802 711 4 2 daehan /en/culture/farm/daehan/
803 711 4 3 green /en/culture/farm/green/
801 711 4 1 ungchi /en/culture/farm/ungchi/
709 696 3 3 foods /en/culture/foods/
755 709 4 1 1 /en/culture/foods/01/
756 709 4 2 2 /en/culture/foods/02/
757 709 4 3 3 /en/culture/foods/03/
758 709 4 4 4 /en/culture/foods/04/
759 709 4 5 5 /en/culture/foods/05/
760 709 4 6 6 /en/culture/foods/06/
761 709 4 7 7 /en/culture/foods/07/
762 709 4 8 8 /en/culture/foods/08/
707 696 3 1 guidemap /en/culture/guidemap/
726 707 4 1 1 /en/culture/guidemap/01/
727 707 4 2 2 /en/culture/guidemap/02/
728 707 4 3 3 /en/culture/guidemap/03/
729 707 4 4 4 /en/culture/guidemap/04/
730 707 4 5 5 /en/culture/guidemap/05/
731 707 4 6 6 /en/culture/guidemap/06/
732 707 4 7 7 /en/culture/guidemap/07/
733 707 4 8 8 /en/culture/guidemap/08/
734 707 4 9 9 /en/culture/guidemap/09/
735 707 4 10 10 /en/culture/guidemap/10/
736 707 4 11 11 /en/culture/guidemap/11/
737 707 4 12 12 /en/culture/guidemap/12/
738 707 4 13 13 /en/culture/guidemap/13/
739 707 4 14 14 /en/culture/guidemap/14/
740 707 4 15 15 /en/culture/guidemap/15/
741 707 4 16 16 /en/culture/guidemap/16/
742 707 4 17 17 /en/culture/guidemap/17/
743 707 4 18 18 /en/culture/guidemap/18/
744 707 4 19 19 /en/culture/guidemap/19/
745 707 4 20 20 /en/culture/guidemap/20/
746 707 4 21 21 /en/culture/guidemap/21/
747 707 4 22 22 /en/culture/guidemap/22/
748 707 4 23 23 /en/culture/guidemap/23/
710 696 3 4 historic /en/culture/historic/
793 710 4 3 assets /en/culture/historic/assets/
794 793 5 1 1 /en/culture/historic/assets/01/
795 793 5 2 2 /en/culture/historic/assets/02/
797 793 5 3 3 /en/culture/historic/assets/03/
798 793 5 4 4 /en/culture/historic/assets/04/
800 793 5 6 5 /en/culture/historic/assets/05/
799 793 5 5 6 /en/culture/historic/assets/06/
763 710 4 1 national /en/culture/historic/national/
764 763 5 1 1 /en/culture/historic/national/01/
765 763 5 2 2 /en/culture/historic/national/02/
766 763 5 3 3 /en/culture/historic/national/03/
768 763 5 4 4 /en/culture/historic/national/04/
770 763 5 5 5 /en/culture/historic/national/05/
771 763 5 6 6 /en/culture/historic/national/06/
772 763 5 7 7 /en/culture/historic/national/07/
774 763 5 8 8 /en/culture/historic/national/08/
775 763 5 9 9 /en/culture/historic/national/09/
776 763 5 10 10 /en/culture/historic/national/10/
777 763 5 11 11 /en/culture/historic/national/11/
778 763 5 12 12 /en/culture/historic/national/12/
779 763 5 13 13 /en/culture/historic/national/13/
773 710 4 2 provincial /en/culture/historic/provincial/
780 773 5 1 1 /en/culture/historic/provincial/01/
781 773 5 2 2 /en/culture/historic/provincial/02/
782 773 5 3 3 /en/culture/historic/provincial/03/
783 773 5 4 4 /en/culture/historic/provincial/04/
784 773 5 5 5 /en/culture/historic/provincial/05/
785 773 5 6 6 /en/culture/historic/provincial/06/
786 773 5 7 7 /en/culture/historic/provincial/07/
787 773 5 8 8 /en/culture/historic/provincial/08/
788 773 5 9 9 /en/culture/historic/provincial/09/
789 773 5 10 10 /en/culture/historic/provincial/10/
790 773 5 11 11 /en/culture/historic/provincial/11/
791 773 5 12 12 /en/culture/historic/provincial/12/
792 773 5 13 13 /en/culture/historic/provincial/13/
708 696 3 2 places /en/culture/places/
749 708 4 1 1 /en/culture/places/01/
750 708 4 2 2 /en/culture/places/02/
751 708 4 3 3 /en/culture/places/03/
752 708 4 4 4 /en/culture/places/04/
753 708 4 5 5 /en/culture/places/05/
754 708 4 6 6 /en/culture/places/06/
712 696 3 6 spring /en/culture/spring/
804 712 4 2 efficacy /en/culture/spring/efficacy/
796 712 4 1 spring /en/culture/spring/spring/
1017 712 4 3 transport /en/culture/spring/transport/
697 693 2 4 greentea /en/greentea/
717 697 3 4 darye /en/greentea/darye/
714 697 3 1 efficacy /en/greentea/efficacy/
716 697 3 3 kinds /en/greentea/kinds/
715 697 3 2 specialty /en/greentea/specialty/
699 693 2 6 investment /en/investment/
720 699 3 1 advantage /en/investment/advantage/
722 699 3 3 condition /en/investment/condition/
723 699 3 4 enterprise /en/investment/enterprise/
840 723 4 1 1 /en/investment/enterprise/01/
841 723 4 2 2 /en/investment/enterprise/02/
842 723 4 3 3 /en/investment/enterprise/03/
843 723 4 4 4 /en/investment/enterprise/04/
844 723 4 5 5 /en/investment/enterprise/05/
847 723 4 6 6 /en/investment/enterprise/06/
849 723 4 7 7 /en/investment/enterprise/07/
854 723 4 8 8 /en/investment/enterprise/08/
855 723 4 9 9 /en/investment/enterprise/09/
858 723 4 10 10 /en/investment/enterprise/10/
863 723 4 11 11 /en/investment/enterprise/11/
864 723 4 12 12 /en/investment/enterprise/12/
721 699 3 2 proximity /en/investment/proximity/
698 693 2 5 product /en/product/
719 698 3 2 arts /en/product/arts/
835 719 4 2 brassware /en/product/arts/brassware/
838 719 4 4 dyeing /en/product/arts/dyeing/
832 719 4 1 hemp /en/product/arts/hemp/
837 719 4 3 pottery /en/product/arts/pottery/
839 719 4 5 yong /en/product/arts/yong/
718 698 3 1 crops /en/product/crops/
809 718 4 1 1 /en/product/crops/01/
810 718 4 2 2 /en/product/crops/02/
811 718 4 3 3 /en/product/crops/03/
812 718 4 4 4 /en/product/crops/04/
813 718 4 5 5 /en/product/crops/05/
814 718 4 6 6 /en/product/crops/06/
815 718 4 7 7 /en/product/crops/07/
816 718 4 8 8 /en/product/crops/08/
817 718 4 9 9 /en/product/crops/09/
818 718 4 10 10 /en/product/crops/10/
819 718 4 11 11 /en/product/crops/11/
820 718 4 12 12 /en/product/crops/12/
822 718 4 14 13 /en/product/crops/13/
821 718 4 13 14 /en/product/crops/14/
823 718 4 15 15 /en/product/crops/15/
824 718 4 16 16 /en/product/crops/16/
827 718 4 17 17 /en/product/crops/17/
828 718 4 18 18 /en/product/crops/18/
831 718 4 19 19 /en/product/crops/19/
830 718 4 20 20 /en/product/crops/20/
829 718 4 21 21 /en/product/crops/21/


[Top]
No.
제목
작성자
작성일
조회
25031[정말 해결책이 없을 까요]mysql 한글문제 [1]
정영
2006-01-26
2621
25030업로드시 에러 문제해결 부탁드립니다.
김명수
2006-01-26
1099
25029mysql 3.23.58에서 백업한것을 --> 4.0.20로
김대종
2006-01-26
1153
25027Tree구조로 select하기..
노지심
2006-01-25
1667
25025핫백업 받아서 replication 구성시 [1]
게스트
2006-01-25
3330
25024잘되던 mysql이 mysql.sock' (11) 이런에러가 납니다. [1]
naya
2006-01-25
1783
25023디비서버를 복구하려고 하는데요..ㅠ [1]
송경선
2006-01-25
1165
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다