묻고답하기
원본을 안건드리고 join시키기.
2011.03.22 15:10
document 모듈을 안건들이고 외부모듈에서 Document 에 다른테이블을 document_srl에 의거하여 join시키고싶어요 다음과같은 쿼리를 짜긴했습니다만...
막상 입히려니 오류가 많네요. 검색조건을 좀 다양화해야해서 (동시에 여러칼럼을 검색하게..) 피할수없이 저렇게짰습니다만;; 왠만하면 xml쿼리처리하려고 하다보니 너무일이많네요; ㅠ 그냥 sql처리할까요??
아니면 따로따로 excute 하여 일일이 add시키는방법도 생각중입니다만... 그거밖엔없을까요? 그렇게하면 테이블다섯개..document까지 쿼리여섯번...해야되는데다가...
검색부분에서 documents 보단 칼럼명보시면 대충감오시겠지만 content나 teacher쪽이 훨씬 검색중요도가 높습니다. 전부다 like처리하여 당연히 동시에일치하는값검색도 되게해야하구요; 아래는 쿼리입니다.
<tables>
<table name="documents" />
<table name="learningme_content" alias="content" type="left join" >
<conditions>
<condition operation="equal" column="content.document_srl" default="documents.document_srl" pipe="and" />
</conditions>
</table>
<table name="learningme_teacher" alias="teacher" type="left join" >
<conditions>
<condition operation="equal" column="teacher.document_srl" default="documents.document_srl" pipe="and" />
</conditions>
</table>
<table name="learningme_mapdata" alias="mapdata" type="left join" >
<conditions>
<condition operation="equal" column="mapdata.document_srl" default="documents.document_srl" pipe="and" />
</conditions>
</table>
<table name="learningme_status" alias="status" type="left join" >
<conditions>
<condition operation="equal" column="status.document_srl" default="documents.document_srl" pipe="and" />
</conditions>
</table>
</tables>
<columns>
<column name="documents.*" />
<column name="content.category1" alias="category1" >
<column name="content.category2" alias="category2" >
<column name="content.category3" alias="category3" >
<column name="content.subtitle" alias="subtitle" >
<column name="content.document_type" alias="document_type" >
<column name="content.member_count" alias="member_count" >
<column name="content.target" alias="target" >
<column name="content.old_limit" alias="old_limit" >
<column name="content.lear_day" alias="lear_day" >
<column name="content.lear_time" alias="lear_time" >
<column name="content.lear_company" alias="lear_company" >
<column name="content.lear_charge" alias="lear_charge" >
<column name="content.lear_homepage" alias="homepage" >
<column name="content.lear_phone" alias="lear_phone" >
<column name="content.lear_mail" alias="lear_mail" >
<column name="content.apply_date" alias="apply_date" >
<column name="content.cancel_day" alias="cancel_day" >
<column name="content.signup_method" alias="signup_method" >
<column name="content.lear_pay" alias="lear_pay" >
<column name="content.lear_support" alias="lear_support" >
<column name="content.ttable_check" alias="ttable_check" >
<column name="mapdata.city1" alias="city1" >
<column name="mapdata.city2" alias="city2" >
<column name="mapdata.city3" alias="city3" >
<column name="mapdata.city4" alias="city4" >
<column name="mapdata.city5" alias="city5" >
<column name="mapdata.road_description" alias="road_description" >
<column name="mapdata.lat" alias="lat" >
<column name="mapdata.lon" alias="lon" >
<column name="mapdata.pano" alias="pano" >
<column name="mapdata.tilt" alias="tilt" >
<column name="mapdata.pan" alias="pan" >
<column name="mapdata.zoom" alias="zoom" >
<column name="teacher.target_srl" alias="target_srl" >
<column name="teacher.image_url" alias="image_url" >
<column name="teacher.sub_name" alias="sub_name" >
<column name="teacher.teacher_name" alias="teacher_name" >
<column name="teacher.teacher_homepage" alias="teacher_homepage" >
<column name="teacher.teacher_blog" alias="teacher_blog" >
<column name="teacher.teacher_email" alias="teacher_email" >
<column name="teacher.teacher_history" alias="teacher_history" >
<column name="teacher.teacher_subject" alias="teacher_subject" >
<column name="status.status" alias="status" >
<column name="status.description" alias="description" >
<column name="status.log" alias="log" >
</columns>
<conditions>
<condition operation="in" column="module_srl" var="module_srl" filter="number" />
<condition operation="notin" column="module_srl" var="exclude_module_srl" filter="number" pipe="and" />
<condition operation="in" column="category_srl" var="category_srl" pipe="and" />
<condition operation="equal" column="is_notice" var="s_is_notice" pipe="and" />
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
<group pipe="and">
<condition operation="more" column="list_order" var="division" pipe="and" />
<condition operation="below" column="list_order" var="last_division" pipe="and" />
</group>
<group pipe="and">
<condition operation="like" column="title" var="s_title" />
<condition operation="like" column="content" var="s_content" pipe="or" />
<condition operation="like" column="user_name" var="s_user_name" pipe="or" />
<condition operation="like" column="user_id" var="s_user_id" pipe="or" />
<condition operation="like" column="nick_name" var="s_nick_name" pipe="or" />
<condition operation="like" column="email_address" var="s_email_addres" pipe="or" />
<condition operation="like" column="homepage" var="s_homepage" pipe="or" />
<condition operation="like" column="tags" var="s_tags" pipe="or" />
<condition operation="equal" column="is_secret" var="s_is_secret" pipe="or" />
<condition operation="equal" column="member_srl" var="s_member_srl" pipe="or" />
<condition operation="more" column="readed_count" var="s_readed_count" pipe="or" />
<condition operation="more" column="voted_count" var="s_voted_count" pipe="or" />
<condition operation="more" column="comment_count" var="s_comment_count" pipe="or" />
<condition operation="more" column="trackback_count" var="s_trackback_count" pipe="or" />
<condition operation="more" column="uploaded_count" var="s_uploaded_count" pipe="or" />
<condition operation="like_prefix" column="regdate" var="s_regdate" pipe="or" />
<condition operation="like_prefix" column="last_update" var="s_last_update" pipe="or" />
<condition operation="like_prefix" column="ipaddress" var="s_ipaddress" pipe="or" />
</group>
<group pipe="and">
<condition operation="more" column="last_update" var="start_date" pipe="and" />
<condition operation="less" column="last_update" var="end_date" pipe="and" />
</group>
</conditions>
<navigation>
<index var="sort_index" default="list_order" order="order_type" />
<list_count var="list_count" default="20" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
<groups>
<group column="documents.document_srl" />
</groups>