如何在访问中结合这两列 [英] How can I combine these two columns in access

查看:39
本文介绍了如何在访问中结合这两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我具有以下条件,我试图根据表中其他两个列的值(本例中为semester和student_name)在访问查询中合并两列(来自单独的表):

I am attempting to combine two columns (from separate tables) in an access query based on the value of 2 other columns in the tables (semester and student_name in this instance), for instance if I had the following:

如何查询以获得最终结果:

how could I make a query to get the final result of:

其中some_data的第三和第四学期(仅第三和第四)部分是根据student_name组合的(一个表中可能有一些名称,而另一个表中没有,等等,尽管未在表中显示)这些示例).目前,我对访问查询还没有很丰富的经验,因此我很难做到这一点.非常感谢您的帮助!

where the third and fourth semester (only the third and fourth) sections of some_data have been combined based on student_name (there may be some names that are in one table, but not in another, etc, although that is not shown in these examples). I am not very experienced with access queries at this point in time, so I am having a difficult time accomplishing this. Any help is much appreciated, thanks!

推荐答案

UPDATE Sheet1 INNER JOIN Sheet2 
ON Sheet1.semester = Sheet2.semester
And  Sheet1.Student_name = Sheet2.Student_name
SET Sheet2.Some_data = Sheet1.Some_Data
Where Sheet1.semester in (3,4)

如果只想在应用结果之前查看结果,则可以单击Datasheet View按钮而不是Run按钮.

If you just want to see the results before they are applied you can click the Datasheet View button instead of the Run button.

如果您希望完整保留两个表并仅查看视图,可以执行以下操作:

If you want to leave your two tables intact and just have a view you can do this:

Select Sheet2.semester
, Sheet2.student_name
, Nz(Sheet2.some_data,Sheet1.some_data)
From Sheet1 INNER JOIN Sheet2 
ON Sheet1.semester = Sheet2.semester
And  Sheet1.Student_name = Sheet2.Student_name

带有可选的where子句

Where Sheet1.semester in (3,4)

Nz 函数此处使用第一个参数中的数据除非该参数为null,否则它将使用第二个参数中的值.

The Nz function here uses data from the first parameter unless that parameter is null, in which case it uses the value from the second parameter.

这篇关于如何在访问中结合这两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆