교육센터에서 배울땐 오라클로 했었는데
Oracle 에서 페이징 할때 쿼리
select * from
(select rownum rm, board.* from
(select * from article order by writenum desc) board)
where rm between ? and ?
Mysql 에서 페이징 할때 쿼리
SELECT *
FROM
(SELECT @ROWNUM :=@ROWNUM +1 AS ROW, A.*
FROM (SELECT * FROM BOARD ORDER BY WRITENUM DESC) A, (SELECT @ROWNUM := 0) B) C
WHERE C.ROW BETWEEN ? AND ?
쿼리 추가 insert
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','four','test1',0,now());
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','five','test2',0,now());
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','six','test3',0,now());
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','seven','test4',0,now());
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','eight','test5',0,now());
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','nine','test6',0,now());
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','ten','test7',0,now());
INSERT INTO BOARD (id,title,content,hit,writedate) VALUES ('taehun','eleven','test8',0,now());
'Web > 게시판' 카테고리의 다른 글
BoardDao 최종 (0) | 2012.08.23 |
---|---|
BoardDao 추가 (0) | 2012.08.23 |
전체글 갯수 구하기 (0) | 2012.08.20 |
list.jsp 및 결과 (0) | 2012.08.19 |
BoardDao 추가 (0) | 2012.08.19 |