SQL中的多个左联接

SQL中的多个左联接

本文介绍了替换Access SQL中的多个左联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 ms access 中为三个表"Process Name","Work_Log1"和"ACn_reviewer"编写查询.

I m writing a query in ms access for three tables "Process Name", "Work_Log1" and "ACn_reviewer".

现在,"Work_Log1"表具有指向"Process NAme"和"ACN_REviewer"表的外键.

Now the "Work_Log1" table is having foreign keys to the "Process NAme" and "ACN_REviewer" table.

但是"Work_log1"表的"ACN_Reviewer"表的某些行中具有空值.

But the "Work_log1" table is having null values in some rows for "ACN_Reviewer" table.

我提出了有效查询

select w.[activity_id], w.[activity_start_date], w.[reporting month] ,
r.[Reviewer_Name] , p.[process_name]
from [process name] p left join
([work_log1] w left join [acn_reviewer] r
on w.[ACN Reviwer] = r.[ACN_Reviewer_ID]  )
on w.[process] = p.[process_id]
 where w.[activity_id] = 54447

现在我知道在work_log1表中没有进程ID为空.

now i know that there are no process ids null in the work_log1 table.

我问的问题是否有某种方法可以在没有联接的情况下进行上述查询?

The question i ask is there some way to do the above query without the joins?

类似这样,仅在acn_reviewer上左加入

Something like this, left join only on acn_reviewer

 select w.[activity_id], w.[activity_start_date], w.[reporting month] ,
r.[Reviewer_Name] , p.[process_name]
from [process name] p  ,   [work_log1] w left join [acn_reviewer] r
 on w.[ACN Reviwer] = r.[ACN_Reviewer_ID]
  where w.[process] = p.[process_id] and
  w.[activity_id] = 54447

我希望现在我能清除

我可以在sql中写这样的东西吗,这在ms-access中引发错误

So can i write something like this in the sql, which is throwing error in ms-access

select w.[activity_id], w.[activity_start_date], w.[reporting month] ,
r.[Reviewer_Name] , p.[process_name] from [process name] p, [work_log1] w
left join [acn_reviewer] r
on w.[ACN Reviwer] = r.[ACN_Reviewer_ID]  on w.[process] = p.[process_id]
 where w.[activity_id] = 54447 ;

谢谢

Pradyut

推荐答案

从上面的属性中收集的信息:

From what I gathered from the attributes above:

Process Name (p)
p.[process_name]
p.[process_id]

Work_Log1 (w)
w.[activity_id]
w.[process]
w.[acn reviwer]
w.[activity_start_date]
w.[reporting month]

ACN Reviewer (r)
r.[acn_reviewer_id]
r.[reviewer_name]

Process NameACN Reviewer有何关系?如果不是,则无法根据Work_Log1中的NULL值来桥接它们.

How are Process Name and ACN Reviewer related? If they aren't, there is no way to bridge them based on a NULL value in Work_Log1.

这篇关于替换Access SQL中的多个左联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 12:17