ji-0630 / CodingTest

코딩테스트 연습 기록
0 stars 0 forks source link

조회수가 가장 많은 중고거래 게시판의 첨부파일 조회하기 #244

Closed ji-0630 closed 1 year ago

ji-0630 commented 1 year ago

문제 설명

image image

ji-0630 commented 1 year ago

다른 사람의 풀이

SELECT concat("/home/grep/src/",  b.BOARD_ID , "/", f.FILE_ID, f.FILE_NAME, f.FILE_EXT) as "FILE_PATH"
from USED_GOODS_BOARD b inner join USED_GOODS_FILE f
on b.BOARD_ID = f.BOARD_ID
WHERE VIEWS = (SELECT MAX(VIEWS) FROM USED_GOODS_BOARD)
order by f.FILE_ID desc

*concat(): 글자 이어붙이는 함수

ji-0630 commented 1 year ago

다시 풀기

SELECT concat("/home/grep/src/", f.BOARD_ID, "/", FILE_ID, FILE_NAME, FILE_EXT) as "FILE_PATH"
from USED_GOODS_BOARD b join USED_GOODS_FILE f
on b.BOARD_ID = f.BOARD_ID
where b.BOARD_ID = (select BOARD_ID
                    from USED_GOODS_BOARD
                     order by VIEWS desc
                     limit 1) 

order by FILE_ID desc