묻고답하기
XML 쿼리문 작성 좀 도와주세요. ㅠ.ㅜ
2018.06.14 01:09
SQL 쿼리는 작성을 했는데, 이걸 XML 쿼리로 바꾸려니 어떻게 해야할지 모르겠네요.
select doc.module_srl, doc.module_srl, doc.category_srl, doc.title, doc.nick_name, ex_v1.value, ex_v2.value
from cam_documents doc
inner join cam_document_extra_vars ex_v1 on doc.document_srl = ex_v1.document_srl
inner join cam_document_extra_vars ex_v2 on ex_v1.document_srl = ex_v2.document_srl
WHERE ex_v1.var_idx = 6 and ex_v1.value > ka and ex_v1.value < ja and
ex_v2.var_idx = 7 and ex_v2.value > da and ex_v2.value < ia
GROUP BY ex_v1.document_srl
아래처럼 해 봤는데, 동작을 안 합니다. XML 쿼리에 아직 익숙치 않아서, 조금만 복잡해져도 잘 모르겠네요. 사실 SQL도 익숙치 않아서 위의 쿼리가 최선인지는 모르겠습니다. 원하는 결과는 나오는데...
<query id="getPinnedPlaces" action="select">
<tables>
<table>
<table name="documents" alias="doc" />
</table>
<table name="document_extra_vars" alias="ex_v1" type="inner join">
<conditions>
<condition operation="equal" column="ex_v1.document_srl" default="doc.document_srl" />
</conditions>
</table>
<table name="document_extra_vars" alias="ex_v2" type="inner join">
<conditions>
<condition operation="equal" column="ex_v2.document_srl" default="ex_v1.document_srl" />
</conditions>
</table>
<conditions>
<condition operation="equal" column="ex_v1.var_idx" default="6" />
<condition operation="excess" column="ex_v1.var_idx" var="ka" notnull="notnull" pipe="and" />
<condition operation="below" column="ex_v1.var_idx" var="ja" notnull="notnull" pipe="and" />
<condition operation="equal" column="ex_v2.var_idx" default="7" pipe="and" />
<condition operation="excess" column="ex_v2.var_idx" var="da" notnull="notnull" pipe="and" />
<condition operation="below" column="ex_v2.var_idx" var="ia" notnull="notnull" pipe="and" />
</conditions>
<groups>
<group column="GroupBy ex_v1.document_srl" />
</groups>
</tables>
<columns>
<column name="doc.module_srl" alias="module_srl" />
<column name="doc.member_srl" alias="member_srl" />
<column name="doc.category_srl" alias="category_srl" />
<column name="doc.title" alias="title" />
<column name="doc.nick_name" alias="nick_name" />
<column name="ex_v1.value" alias="lat" />
<column name="ex_v2.value" alias="lng" />
</columns>
</query>
댓글 2
-
큰돌♡
2018.06.19 15:09
답변 고맙습니다. XML 쿼리에서 기본적인 join은 되는데, 조금 복잡하게 테이블 세 개를 join하는 형태로 하니 해석을 못하는 것 같더군요. 다른 방법을 써서 해결했습니다.
글쓴이 | 제목 | 최종 글 |
---|---|---|
XE | 공지 글 쓰기,삭제 운영방식 변경 공지 [16] | 2019.03.05 by 남기남 |
권대권 | 비밀번호 찾기 정보란 수정이 안됩나다. [4] | 2018.06.21 by 권대권 |
허원정 |
상품타입 아무것도 없습니다
![]() | |
쫑쫑이큰누나 |
메인에 있는 위젯 삭제
[1]
![]() | 2018.06.21 by 너에게제공 |
lame**** | marketplace 게시글을 관리자 삭제가능 | |
winner507 | XE 게시판 필터 검사 후 등록 전 결제창 띄우기 도움요청 | |
아티자인 | 관리자로그인하면 아무것도 뜨지 않습니다 [2] | 2018.06.20 by 아티자인 |
탈출 |
질문]회원변경 건
![]() | |
등대 | 아이프레임 동영상(유튜브)위에 레이어 삽입하기?부탁드립니다. [2] | 2018.06.20 by 등대 |
bestpage | 위젯 여백 질문 [1] | 2018.06.20 by 너에게제공 |
아티자인 | HTTP 500 내부 서버 오류 [1] | 2018.06.19 by 너에게제공 |
ecli**** |
답답한 마음에 올려봅니다.. 도와주세요 ㅠ
[5]
![]() | 2018.06.19 by ecli**** |
zzoong2 | 특정사이트가 나타나질않습니다. [1] | 2018.06.19 by dstyle |
DANNY | 누리고 관리자패이지 회원관리 질문입니다. [1] | 2018.06.19 by dstyle |
아티자인 | '기본 URL 설정이 안되어 있습니다' 라고 뜹니다 [1] | 2018.06.19 by dstyle |
큰돌♡ | XML 쿼리문 작성 좀 도와주세요. ㅠ.ㅜ [2] | 2018.06.19 by 큰돌♡ |
쭈니쿠 |
메인비쥬얼 등록은 했는데 움직이지 않습니다.(다시 올립니다)
[1]
![]() | 2018.06.19 by 너에게제공 |
쭈니쿠 | 메인비쥬얼 등록은 했는데 움직이지 않습니다. [1] | 2018.06.19 by dstyle |
SJ_KK3 | PC에 저장된 동영상을 업로드 하고 싶습니다. [1] | 2018.06.19 by dstyle |
작업용 | 게시글관리에 분류가 대체 왜 흰빈칸으로 뜨나요..ㅠ(기본 스킨도 안돼요) | |
가르송 | 카카오톡 api가 바꼈네요 ㅠㅠ |
join 의 예시는
documents/queries/getDocumentListWithExtraVars.xml 파일
documents/queries/getDocumentListWithinExtraVarsExtraSort.xml 파일
members/queries/getMemberListWithinGroup.xml 파일
LEFT JOIN 은 이런형태로도 하고요
documents/queries/getDocumentsExtraVars.xml 파일
등을 참조하시면 이해가 될거예요 ^^