查询MS访问问题

时间:2013-02-03 03:06:14

标签: sql ms-access

我正在使用MS Access

使用以下查询时,当“1”和“2”两个值(SMPHT_Med.StateCode)与“A1”(Lookup2.StateCode中)

时,我无法获得匹配记录

此处SMPHT_LKP_ProOpt是用于匹配SMPHQ_Active_ItemSMPHT_Med之间记录的查找表

基本上,当SMPHT_Med的列中SMPHT_Med.StateCode的列值为{1}时,SMPHT_LKP_ProOpt.State中的“1”和“2”中没有两条记录时,我需要不匹配的记录< / p>

SELECT SMPHQ_Active_Item.SMPHT_Mod.ItemID, SMPHT_LKP_ProOpt.*, SMPHT_Med.*
FROM (SMPHQ_Active_Item 
INNER JOIN SMPHT_LKP_ProOpt ON SMPHQ_Active_Item.Comp = SMPHT_LKP_ProOpt.Comp) 
LEFT JOIN SMPHT_Med ON 
(
    ((SMPHT_LKP_ProOpt.State = SMPHT_Med.StateCode) OR ((SMPHT_LKP_ProOpt.State = 'A1') AND ((SMPHT_Med.StateCode ='1' AND SMPHT_Med.StateCode = '3'))))
    AND (SMPHT_LKP_ProOpt.OptCode = SMPHT_Med.OptCode)
)

干杯

0 个答案:

没有答案