sql - 如何进行自我加入
问题描述
我想做自加入我也写了一个代码,但是它抛出了一个错误,而且别名似乎有一些问题。
除此之外,如果有人让我知道我可以在 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
解决方案
完全不清楚您要做什么。但是,“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
.
推荐阅读
- json - 如何提醒 React-JS 获取值
- r - 我如何遍历 R 中的 S4 对象?
- css - 如何使 CSS 六边形/蜂窝网格(基于集合数学方程)灵活?
- javascript - 表格在 2k 和 4k 显示器上过于放大
- javascript - 未使用的进口量有多大?
- ios - 我收到“线程保持活动状态”和 BundleID message.for HomeKit readValue
- weka - 如何解释 weka 结果
- perl - 在perl中将属性右截断为长度为40的字符串
- c++ - 无法在 CListBoxCtontrol 中使用 SetTabStops
- regex - 为什么正则表达式模式匹配空值