묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
SELECT member_srl, nick_name, message_type FROM brm_member_message, brm_member
where (message_type = 'S' and sender_srl='116' and member_srl = receiver_srl) or (message_type = 'R' and receiver_srl='116' and member_srl = sender_srl) group by member_srl;
위와 같은 sql을 xml로 변환하려고 합니다. 마지막 group by 구문을 어떻게 해야하는지 모르겠네요.
아래와 같이 했더니 group by가 먹지 않습니다.
<query id="getFriends" action="select">
<tables>
<table name="member_message" alias="message" />
<table name="member" alias="member" />
</tables>
<columns>
<column name="member_srl" alias="other_srl" />
<column name="nick_name" />
<column name="message_type" />
<column name="message.regdate" alias="regdate" />
</columns>
<conditions>
<group>
<condition operation="equal" column="message_type" notnull="notnull" default="S" />
<condition operation="equal" column="sender_srl" var="116" notnull="notnull" pipe="and" />
<condition operation="equal" column="member_srl" notnull="notnull" default="receiver_srl" pipe="and" />
</group>
<group pipe="or">
<condition operation="equal" column="message_type" notnull="notnull" default="R" />
<condition operation="equal" column="receiver_srl" var="116" notnull="notnull" pipe="and" />
<condition operation="equal" column="member_srl" notnull="notnull" default="sender_srl" pipe="and" />
</group>
</conditions>
<navigation>
<index var="sort_index" default="message.regdate" order="asc" />
<list_count var="list_count" default="10" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
<groups>
<groups column="member_srl" />
</groups>
</query>
sql에서 group by 는 어떻게 표현하나요?
2011.03.16 16:37
SELECT member_srl, nick_name, message_type FROM brm_member_message, brm_member
where (message_type = 'S' and sender_srl='116' and member_srl = receiver_srl) or (message_type = 'R' and receiver_srl='116' and member_srl = sender_srl) group by member_srl;
위와 같은 sql을 xml로 변환하려고 합니다. 마지막 group by 구문을 어떻게 해야하는지 모르겠네요.
아래와 같이 했더니 group by가 먹지 않습니다.
<query id="getFriends" action="select">
<tables>
<table name="member_message" alias="message" />
<table name="member" alias="member" />
</tables>
<columns>
<column name="member_srl" alias="other_srl" />
<column name="nick_name" />
<column name="message_type" />
<column name="message.regdate" alias="regdate" />
</columns>
<conditions>
<group>
<condition operation="equal" column="message_type" notnull="notnull" default="S" />
<condition operation="equal" column="sender_srl" var="116" notnull="notnull" pipe="and" />
<condition operation="equal" column="member_srl" notnull="notnull" default="receiver_srl" pipe="and" />
</group>
<group pipe="or">
<condition operation="equal" column="message_type" notnull="notnull" default="R" />
<condition operation="equal" column="receiver_srl" var="116" notnull="notnull" pipe="and" />
<condition operation="equal" column="member_srl" notnull="notnull" default="sender_srl" pipe="and" />
</group>
</conditions>
<navigation>
<index var="sort_index" default="message.regdate" order="asc" />
<list_count var="list_count" default="10" />
<page_count var="page_count" default="10" />
<page var="page" default="1" />
</navigation>
<groups>
<groups column="member_srl" />
</groups>
</query>
오타를 냈었네요 킁..
<groups column="member_srl" /> 를 <group column="member_srl" /> 로 바꿔주기만 하니까 되네요.
에구에구...저런 오타를...