게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
sql 쿼리 고수분들께 질문 드립니다.
게시물ID : programmer_3918짧은주소 복사하기
작성자 : 사이키
추천 : 0
조회수 : 551회
댓글수 : 6개
등록시간 : 2014/06/11 11:10:36
옵션
  • 본인삭제금지
제가 쓰는 쿼리가

select 
b.idx as idx,
(select CONCAT(attach_path,'/',attach_savename) from g_attach 
 where b.board_category=board_id and b.idx = board_idx order by attach_idx asc limit 0, 1) as att_file1,
(select CONCAT(attach_path,'/',attach_savename) from g_attach 
 where b.board_category=board_id and b.idx = board_idx order by attach_idx asc limit 1, 1) as att_file2,
(select CONCAT(attach_path,'/',attach_savename) from g_attach 
 where b.board_category=board_id and b.idx = board_idx order by attach_idx asc limit 2, 1) as att_file3,
(select CONCAT(attach_path,'/',attach_savename) from g_attach 
 where b.board_category=board_id and b.idx = board_idx order by attach_idx asc limit 3, 1) as att_file4,
(select CONCAT(attach_path,'/',attach_savename) from g_attach 
 where b.board_category=board_id and b.idx = board_idx order by attach_idx asc limit 4, 1) as att_file5,
(select CONCAT(attach_path,'/',attach_savename) from g_attach 
 where b.board_category=board_id and b.idx = board_idx order by attach_idx asc limit 5, 1) as att_file6
from g_board as b

이런 코드를 짠게 있습니다.
대략적으로 일단 제가 질문드릴 부분만 추린건데요
g_board 테이블에 게시물이 있고
g_attach 테이블에 첨부된 파일이 들어있습니다.
한 게시물당 첨부는 6개 까지 가능하고 첨부를 안할수도 있고 1~5개만 첨부를 할수도 있습니다.
저런식으로 해서 리스트를 뿌려주는데 
저게 결국 select 를 7번이나 하는 격이 되서 쿼리문 자체 실행속도가 매우 느립니다.
저 쿼리문의 실행속도를 빠르게 쿼리 수정이 혹시 가능 할까 해서 여기에 질문글을 올립니다.
참고로  DB는 MySql을 쓰고 있습니다. 
도와주세요..ㅠㅠ
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호