이 쿼리문좀 알려주세요.

조회수 812회

여기 있는 쿼리문들 좀 설명 좀 해주실 수 있을까요?

웹 게시글 페이징 하려고 알아본건데.

알려주실 수 있을까요?

<게시글 검색 쿼리>
String sql = "SELECT * from ( ";
                            sql +="     SELECT  ";
                            sql +="         @rownum:=@rownum+1 as rownum,t.* ";
                            sql +="     FROM  ";
                            sql +="         test t,(select @rownum:=0) rownum  ";
                            sql +=" where 1=1";
                            if(!"".equals(startDate)){
                                sql +="  and  time_stamp between ? and ? ";
                            }
                            if(!"".equals(fileName)){
                                sql +="  and name like ?";
                            }
                            if(!"".equals(word)){
                                sql +="  and story like ?";
                            }
                            sql +=" ) a ";
                            sql +=" where rownum between ? and ? ";
<게시글 카운트 쿼리>
String sql = "SELECT count(*) from ( ";
                sql +="     SELECT  ";
                sql +="         @rownum:=@rownum+1 as rownum,t.* ";
                sql +="     FROM  ";
                sql +="         test t,(select @rownum:=0) rownum  ";
                sql +="     where 1=1 ";
                if(!"".equals(startDate)){
                    sql +=" and  time_stamp between ? and ? ";
                }
                if(!"".equals(fileName)){
                    sql +=" and name like ?";
                }
                if(!"".equals(word)){
                    sql +=" and story like ?";
                }
                sql +=" ) a ";
  • (•́ ✖ •̀)
    알 수 없는 사용자

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

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)