简体   繁体   English

MS Access VBA 查询多个表

[英]MS Access VBA query multiple tables

I have two tables in Access, both have a columns named 'procedure' and 'version'我在 Access 中有两个表,都有一个名为“procedure”和“version”的列
that contain String values包含字符串值

Recorded training Table记录训练表

procedue____________version程序____________版本
PO-123_______________1 PO-123_______________1
PO-123_______________2 PO-123_______________2
PO-123_______________3 PO-123_______________3
PO-456_______________1 PO-456_______________1
PO-456_______________2 PO-456_______________2

Procedures Table程序表

procedue____________version程序____________版本
PO-123_______________4 PO-123_______________4
PO-456_______________3 PO-456_______________3

Recorded training Table contains all the training entered into the system over time,记录培训表包含随着时间的推移进入系统的所有培训,
while Procedures Table contains the most up to date revision for each procedure.而程序表包含每个程序的最新修订。

I need a way of checking if the 'Recorded training Table' contains a record corresponding to a record in 'Procedures Table' (ie the same procedure and correct version), and if not get the highest version for each procedure.我需要一种方法来检查“记录的训练表”是否包含与“程序表”中的记录相对应的记录(即相同的程序和正确的版本),如果没有获得每个程序的最高版本。

Any help would be appreciated!任何帮助将不胜感激!

Cheers干杯

I'd try something like this:我会尝试这样的事情:

SELECT B.procedue, B.MaxVersion, C.version AS CurrentVersion
FROM (
    SELECT A.procedure, MAX(A.version) AS MaxVersion
    FROM [Recorded training] AS A
    GROUP BY A.procedure
    ) AS B INNER JOIN Procedures AS C ON B.procedure = C.procedure

This is also calling: joins .这也叫: joins

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM