我开发了一个带有下一个架构的Access数据库:
第一张表:
第二个表格,通过标识符链接到第一个表格,它被用作历史记录,保留一些事件与他负责:
所以,我正在尝试创建一个SQL查询,通过这种方式为历史表中的最后一个事件提供确定的标识符:
body {
font-family: arial;
}
.sidebar {
position: absolute;
top: 0;
left: -160px;
transition: 100ms left;
height: 100%;
overflow-y: auto;
}
#navigation-toggle {
position: absolute;
left: 160px;
background: rgba(3, 159, 244, .95);
color: white;
text-decoration: none;
padding: 20px;
}
.show {
left: 0;
}
.navigation {
list-style: none;
padding: 0;
margin: 0;
}
.navigation-items a {
display: block;
background-color: #444;
color: white;
line-height: 2em;
text-decoration: none;
padding: 10px 30px;
width: 100px;
}
.navigation-items a:hover {
background-color: #222;
}
.topmenu {
background-color: #f00;
height: 70px;
}
但它带给我的有时历史上的价值不是最后的,为什么可能是原因?
答案 0 :(得分:1)
您需要先将History
分组才能找到最多条目。创建一个子查询,然后使用TABLE1
加入子查询。
看到这个问题的一个很好的例子:
Is it better / more efficient to use sub queries or SELECT statements within the WHERE clause (in MS Access)
(您希望将"组合为单个查询"变体)。
如果您无法使用它,请添加评论。