select ref_idx, file_url+file_name as file_path, case when ref_tb = 'tb_book_file' then item_type when ref_tb = 'tb_book_subContents' then ref_sub else '' end as content_type from nexusbook.dbo.tb_common_fileList a left join (select item_idx, item_type from tb_book_file) b on a.ref_idx = b.item_idx where file_idx = " pID "