테스트 사이트 - 개발 중인 베타 버전입니다

g5_shop_event_item 테이블에 it_id 가 등록된 상품은 무조건 검색이 안되게 하려면 채택완료

GNUAPP 2년 전 조회 1,438

이미 g5_shop_event_item 테이블에 it_id 가 등록된 상품이라도 새 이벤트를 등록하면

g5_shop_event_item 테이블에 등록된 상품이 검색이됩니다.

g5_shop_event_item 테이블에 it_id 가 등록된 상품은 무조건

검색이 안되게 하려면 어떻게해야 될까요? 도움 부탁 드립니다.ㅠ

 

    $("#btn_search_item").click(function() {         var ca_id = $("#sch_ca_id").val();         var it_name = $.trim($("#sch_name").val());

        if(ca_id == "" && it_name == "") {             $("#sch_item_list").html("

상품의 분류를 선택하시거나 상품명을 입력하신 후 검색하여 주십시오.

");             return false;         }

        $("#sch_item_list").load(             "./itemeventsearch.php",             { w: "", ev_id: "", ca_id: ca_id, it_name: it_name }         );     });

    $(document).on("click", "#sch_item_list .add_item", function() {         // 이미 등록된 상품인지 체크         var $li = $(this).closest("li");         var it_id = $li.find("input:hidden").val();         var it_id2;         var dup = false;         $("#reg_item_list input[name='it_id[]']").each(function() {             it_id2 = $(this).val();             if(it_id == it_id2) {                 dup = true;                 return false;             }         });

        if(dup) {             alert("이미 등록된 상품입니다.");             return false;         }

        var cont = "

  • "+$li.html().replace("add_item", "del_item").replace("추가", "삭제")+"
  • ";         var count = $("#reg_item_list li").length;

            if(count > 0) {             $("#reg_item_list li:last").after(cont);         } else {             $("#reg_item_list").html("

      "+cont+"
    ");         }

            $li.remove();     });

    댓글을 작성하려면 로그인이 필요합니다.

    답변 2개

    채택된 답변
    +20 포인트
    플래토
    2년 전

    g5_shop_item에 해당되는

    $g5['g5_shop_item_table']에서

    where it_id=null or it_id = ''

    하면 값은 아무것도 안나올수밖에 없습니다.

     

    g5_shop_item 테이블에서

    it_id는 키값이거든요

     

    찾으시려는게

    g5_shop_event_item 테이블에서 it_id 값이 없는것을 찾으시려는거라면

    원하는 의도가 맞는지 검토해보세요

    왜냐면

     

    g5_shop_event_item 테이블에서도

    ev_id 와 it_id 두개가 키로 정의 되어있거든요

    두개밖에 없는 테이블이라 값이 없다면.. 없는것입니다.

     

    질문의 의도를 잠시 다른방향으로 생각해봤을때

     

    g5_shop_item에 있는 자료중

    g5_shop_event_item 에 등록된 자료를 제외하려는것이라면

     

    select * from g5_shop_item a

    where not exists (select 'x' from g5_shop_event_item b where a.it_id = b.it_id)

    로 하시면 event테이블에 등록된 자료는 제외됩니다.

     

    로그인 후 평가할 수 있습니다

    답변에 대한 댓글 2개

    G
    GNUAPP
    2년 전
    플래토님 답변 감사드립니다. 제가 설명이 많이 부족했네요. g5_shop_item에 있는 자료 중
    g5_shop_event_item 에 등록된 자료를 제외하려는 것이 맞습니다. 아주 잘 동작합니다.ㅜ
    플래토
    2년 전
    @GNUAPP 잘되신다니 다행이네요

    댓글을 작성하려면 로그인이 필요합니다.

    플라이
    2년 전

    itemeventsearch.php 이라는 파일에서 검색을 하는듯 한데

     

    쿼리 부분에서 where 조건문중에 it_id is null 이나 it_id='' 빈값인 경우만 조회가 되도록 처리해 주셔야 합니다.

    로그인 후 평가할 수 있습니다

    답변에 대한 댓글 6개

    G
    GNUAPP
    2년 전
    $sql = " select it_id, it_name
    from {$g5['g5_shop_item_table']}
    where (1) ";
    if($ca_id)
    $sql .= " and ( ca_id like '$ca_id%' or ca_id2 like '$ca_id%' or ca_id3 like '$ca_id%' ) ";

    if($it_name)
    $sql .= " and it_name like '%$it_name%' ";

    $sql .= " order by ca_id, it_name ";
    $result = sql_query($sql);

    플라이님 답변 감사드립니다.
    위 부분에서 가져오는 것 같은데요. where(1) 부분을 어떻게해야 될까요?
    g5_shop_event_item에 it_id가 있으면 제외를 해야 되는데 도움 부탁 드립니다.ㅠ
    플라이
    2년 전
    where it_id='' 로 변경해보세요
    G
    GNUAPP
    2년 전
    답변 감사드려요.
    where it_id='' 로 변경해보았는데요. 다른 상품도 불러오지를 못해요ㅜ
    플라이
    2년 전
    검색시만 말씀하시는거라면
    if($it_name)
    $sql .= " and it_id='' and it_name like '%$it_name%' ";

    이런식으로 검색되도록 해야 합니다.
    G
    GNUAPP
    2년 전
    답변 감사드려요.

    $sql = " select it_id, it_name
    from {$g5['g5_shop_item_table']}
    where it_id='' ";
    if($ca_id)
    $sql .= " and ( ca_id like '$ca_id%' or ca_id2 like '$ca_id%' or ca_id3 like '$ca_id%' ) ";

    if($it_name)
    $sql .= " and it_id='' and it_name like '%$it_name%' ";

    $sql .= " order by ca_id, it_name ";
    $result = sql_query($sql);

    이렇게 적용하였는데, 상품 검색이 안되네요.ㅜㅜ 에구
    플라이
    2년 전
    Where (1)은 처음상태로 처리하셔야 합니다.

    댓글을 작성하려면 로그인이 필요합니다.

    답변을 작성하려면 로그인이 필요합니다.

    로그인