여러 게시판을 불러오는 최신글에서 여분필드 조건 넣기.

여러 게시판을 불러오는 최신글에서 여분필드 조건 넣기.

QA

여러 게시판을 불러오는 최신글에서 여분필드 조건 넣기.

본문

그누보드 - [최신글]원하는 게시판만 선택해서하기 > 그누보드5 팁자료실 (sir.kr)

현재 이 최신글을 잘 사용하고 있는데

wr_3가 체크 되어있는 글들만 불러 오고 싶어서 붉은 부분을 추가해봤는데, 특별한 오류없이 아무 글도 불러지지 않습니다.

 

 

        $list = array();
        $sql_common = " from {$g5['board_new_table']} a  where   find_in_set(a.bo_table, '{$bo_tables}')";
        $sql_common .= " and a.wr_id = a.wr_parent ";
        $sql_common .= " and a.wr_3 != ''"; // 여분필드 wr_3이 빈 문자열이 아닌 경우만 가져옴 
        $sql_order = " order by a.bn_id desc ";
        $sql = " select a.* {$sql_common} {$sql_order}  limit 0 , {$rows}";
       $result = sql_query($sql);

 

sql은 전혀 모르는 초보라, 고수님의 가르침 부탁드립니다. 감사합니다.

이 질문에 댓글 쓰기 :

답변 1

혹시 아래의 코드를 참고 해보시겠어요..

 

1. 

 

$list = array();
$sql_common = " from {$g5['board_new_table']} a ";
$sql_common .= " join {$g5['write_prefix']}b on a.bo_table = b.bo_table and a.wr_id = b.wr_id ";
$sql_common .= " where find_in_set(a.bo_table, '{$bo_tables}')";
$sql_common .= " and a.wr_id = a.wr_parent ";
$sql_common .= " and b.wr_3 != ''"; // 여분필드 wr_3이 빈 문자열이 아닌 경우만 가져옴
$sql_order = " order by a.bn_id desc ";
$sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";
$result = sql_query($sql);
 

 

2.

 

$sql_common = " from {$g5['board_new_table']} a 
                left join {$g5['write_prefix']}".implode(" b on a.bo_table = b.bo_table and a.wr_id = b.wr_id 
                left join {$g5['write_prefix']}", explode(',', $bo_tables))." b on a.bo_table = b.bo_table and a.wr_id = b.wr_id 
                where find_in_set(a.bo_table, '{$bo_tables}')";
$sql_common .= " and a.wr_id = a.wr_parent ";
$sql_common .= " and b.wr_3 = '1'"; // wr_3이 체크된 경우 (체크박스 값이 '1'이라고 가정)
$sql_order = " order by a.bn_id desc ";
$sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";

 

 

 

 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 0
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT