我有一個SQL查詢,如果發現文件將比較來自web_pub_subfile表file_names並顯示信息或沒有多重屬性
SELECT file_name, CASE WHEN EXISTS(SELECT 1
FROM web_pub_subfile t JOIN infocard_1 ic on ic.info_card_id=t.info_card_id
WHERE E.file_name = t.file_name and lower(ic.vault_name) ='SU-SPEC-RELEASE')
THEN 'YES'
ELSE 'NO' END AS File_Found
FROM (VALUES
('00924.dwg'),
('00960.dwg'),
('00973.dwg'),
('00984.dwg'),
('01008.dwg')) E(file_name)
我會得到的輸出格式
file_name File_Found ---------------------- 00924.dwg NO 00960.dwg YES 00973.dwg YES 00984.dwg YES 01008.dwg YES
我可以使用ABOVE查詢從TABLE - > web_pub_subfile顯示2個更多屬性(document_num和vault_name)嗎?
file_name File_Found document_num vault ----------------------------------------------------- 00924.dwg NO Test1 SU-SPEC-RELEASE 00960.dwg YES Test2 SU-SPEC-RELEASE 00973.dwg YES Test3 SU-SPEC-RELEASE 00984.dwg YES Test4 SU-SPEC-RELEASE 01008.dwg YES Test5 SU-SPEC-RELEASE
提供web_pub_subfile和infocard_1表DEF。 – Esty
即使沒有找到文件,你如何在第一行得到'Test1','SU-SPEC-RELEASE' –
@Prdp第二個輸出就是例子。我試圖從web_pub_subfile獲取該信息TABLE –