最後の試み: 私は考えています.. おそらく、work_log1 が acn_reviewer に結合されたまま (最初に work_log1 をプロセスに結合せずに)、それらの結果を別の選択に結合して、プロセスが null で acn_reviewer がそうでない状況を取得したいと考えていますか? はい?番号...?知るか。つかれた。アクセスでは完全な外部結合などが許可されていないので....おそらくそれがあなたが実際にやろうとしていることですか?
select pw.[activity_id],
pw.[activity_start_date],
pw.[reporting month] ,
r.[Reviewer_Name],
pw.[process_name]
from ([work_log1] as w
join [process name] as p
on w.[process] = p.[process_id] ) as pw
join [acn_reviewer] as r
on pw.[ACN Reviwer] = r.[ACN_Reviewer_ID]
where pw.[activity_id] = 54447
-- all records in work_log1 that have a matching row both
-- in acn_reviewer and process via the join
union
select pw.[activity_id],
pw.[activity_start_date],
pw.[reporting month] ,
null as [Reviewer_Name],
pw.[process_name]
from ([work_log1] as w
join [process name] as p
on w.[process] = p.[process_id] ) as pw
left join [acn_reviewer] as r
on pw.[ACN Reviwer] = r.[ACN_Reviewer_ID]
where pw.[activity_id] = 54447 and r.[acn reviewer] is null
-- all records where work_log1, WITH a row in process,
-- WITHOUT a row in acn_reviewer
union
select pw.[activity_id],
pw.[activity_start_date],
pw.[reporting month] ,
r.[Reviewer_Name] as [Reviewer_Name],
null as [process_name]
from ([work_log1] as w
join [acn_reviewer] as r
on w.[ACN Reviwer] = r.[ACN_Reviewer_ID] ) as wr
left join [process name] as p
on w.[process] = p.[process_id]
where pw.[activity_id] = 54447 and p.[process_id] is null
-- all records where work_log1, WITHOUT a row in process,
-- WITH a row in acn_reviewer
union
select pw.[activity_id],
pw.[activity_start_date],
pw.[reporting month] ,
null as [Reviewer_Name],
null as [process_name]
from ([work_log1] as w
left outer join [acn_reviewer] as r
on w.[ACN Reviwer] = r.[ACN_Reviewer_ID] ) as wr
left outer join [process name] as p
on wr.[process] = p.[process_id]
where pw.[activity_id] = 54447 and p.[process_id] is null and wr.[ACN_Reviewer_ID] is null
-- all records in work_log1 that have no matching rows in either process or acn_reviewier
-- cuzzz its a left outer join and the where says the joined tables return null-thing
アクセスは奇妙で、そのすべてをaに入れると気に入るか気に入らないかもしれませんが、よくselect * from (query with unions) as x where activity_id = 54447
わかりません。私はこれをテストしていません。しかし、うまくいけばアイデアが得られます。うまくいけば、これはあなたが望むものです。*そうでない場合 ---> njk のような ERD は、私たち/あなたが正しければ (b/c あなたは彼が間違っていると言った)、非常に役に立ちます。それがなくても、必要な NULL を示す結果セットの例がなくても、続行できません。*
または...最初のクエリで結合が削除されましたか?
select w.[activity_id],
w.[activity_start_date],
w.[reporting month],
r.[Reviewer_Name],
p.[process_name]
from work_log1 as w, acn_reviewer as r, process as p
where (w.[acn reviewer] = r.acn_reviewer_id or r.acn_reviewer_id is null) and
w.process = p.process_id