我试图使用LEFT JOIN
基于他们的列加入两个表SELECT DISTINCT ic.document_num, wps.file_name
FROM web_pub_subfile wps
LEFT JOIN infocard_1 ic ON ic.info_card_id = wps.info_card_id
AND lower(ic.vault_name) LIKE N'%su-spec-release%'
WHERE wps.file_name IN ('00350.dwg','00924.dwg','00960.dwg','00973.dwg');
我以这种格式获得输出
document_num file_name ------------------------- NULL 00924.DWG NULL 00960.DWG NULL 00973.DWG SU-SH3A081 00960.DWG SU-SH3A148 00973.DWG
问题在于,它没有显示任何有关
00350.dwg的内容,并在
00960.DWG and 00973.DWG上显示重复的空值
预期的输出
document_num file_name ------------------------- NULL 00350.DWG NULL 00924.DWG SU-SH3A081 00960.DWG SU-SH3A148 00973.DWG
有人可以帮助我吗?
答案 0 :(得分:0)
这样的事情应该符合期望,我希望......
SELECT DISTINCT
ic.document_num,
wps.file_name
FROM web_pub_subfile wps
LEFT JOIN infocard_1 ic ON ic.info_card_id = wps.info_card_id
WHERE ic.vault_name LIKE N'%su-spec-release%'
AND ic.document_num IS NOT NULL
AND wps.file_name IN ('00350.dwg', '00924.dwg', '00960.dwg', '00973.dwg')
答案 1 :(得分:0)
SELECT DISTINCT
ic.document_num,
wps.file_name
FROM
web_pub_subfile wps
LEFT JOIN infocard_1 ic
ON ic.info_card_id = wps.info_card_id
AND lower(ic.vault_name) LIKE N'%su-spec-release%'
AND wps.file_name IN ('00350.dwg','00924.dwg','00960.dwg','00973.dwg');
我希望这种语法可以帮到你!