-->

MY-SQL

 

 

1)심플 쿼리

select * from tbl_board 
where ( bno = IFNULL((select min(bno) from tbl_board where bno > 134),0) 
 		or  bno = IFNULL((select max(bno) from tbl_board where bno = 134),0)
        or  bno = IFNULL((select max(bno) from tbl_board where bno < 134),0)
)


 

 

2)유저 테이블 조인 및  이전 현재 다음 상태 true , false 값  출력

select  a.bno, a.uid,  a.title ,username ,`level` , boardType, boardSubType ,a.createdDate ,
 
 IF ( bno < 134, 'true', 'false') as `prev` , IF ( bno =134, 'true', 'false') as `curr`, IF ( bno > 134, 'true', 'false') as `next` from (

select  bno, uid,  title , boardType, boardSubType,  createdDate  from tbl_board 
where ( bno = IFNULL((select min(bno) from tbl_board where bno > 134  and boardType='qna' ),0) 

 		or  bno = IFNULL((select max(bno) from tbl_board where bno = 134   and boardType='qna'  ),0)
        or  bno = IFNULL((select max(bno) from tbl_board where bno < 134  and boardType='qna' ) ,0)
)
) a join tbl_user tu on a.uid=tu.uid 


 

 

 

 

 

 

 

 

 

 

 

spring

 

about author

PHRASE

Level 1  라이트

댓글 ( 4)

댓글 남기기

작성