首页 > 解决方案 > 如何进行自我加入

问题描述

我想做自加入我也写了一个代码,但是它抛出了一个错误,而且别名似乎有一些问题。

除此之外,如果有人让我知道我可以在 MS Access 中学习查询的任何最佳站点,这对我也会有所帮助。我到处搜索了很多地方,它通过 UI 界面显示,但我想在 MS Access 中学习查询。

(SELECT distinct  itemname,vendorname,price,count(*)
from vendor_Details1
group by itemname,vendorname,price
order by vendorname) A
inner join
(SELECT distinct  itemname,vendorname,price,count(*)
from vendor_Details1
group by itemname,vendorname,price
order by vendorname) B
on A.vendorname=B.vendorname

标签: sqlms-accessms-access-2010

解决方案


完全不清楚您要做什么。但是,“join”是FROM子句中对两个表、视图或子查询进行操作的运算符。

自联接的结构如下所示:

select . . .              -- list of columns here
from t as t1 inner join   -- you need aliases for the table so you can distinguish the references
     t as t2
     on t1.? = t2.?       -- the join condition goes here

您的查询甚至没有select.


推荐阅读