简体   繁体   English

有没有办法计算另一个表中的行数,由当前表的值给出

[英]Is there a way to count rows from another table, given by values of current table

We have a production server through access with about 130 tables, management wants to add a table that gives the count of all the rows in each table;我们有一个通过访问的生产服务器,大约有 130 个表,管理层想要添加一个表,该表给出每个表中所有行的计数; IE table with the name of [53462] has 10678 rows.名称为 [53462] 的 IE 表有 10678 行。 We have a table that contains the nice name and true name of all of the tables and they would like all the counted rows in another column of that same table.我们有一个表,其中包含所有表的好听的名称和真实名称,他们想要同一个表的另一列中的所有计数行。

My current solution which is a little taxing is to use an external program to write up a CSV file that goes through all the tables and runs a COUNT statement, obviously, this is a very slow process and often results in mistakes on number accounting due to the number of rows changing so often in the tables.我目前有点费力的解决方案是使用外部程序编写一个 CSV 文件,该文件遍历所有表并运行 COUNT 语句,显然,这是一个非常缓慢的过程,并且经常导致数字记帐错误表中经常变化的行数。

Our tables all have names like 02461, 02623 save for the Key table that has all of the names in it.我们的表都有像 02461、02623 这样的名称,除了包含所有名称的 Key 表。 The key table looks like the following, names changed for security,密钥表如下所示,为安全起见更改了名称,

|ID|       Title      |Part Number|
|24|Bob Jones         |02461      |
|34|Jacob Statham     |02623      |
etc.

Whereas the output they want, and our awkward solution shows, is:而他们想要的输出,我们笨拙的解决方案显示,是:

|ID|       Title      |Part Number|Rows |
|24|Bob Jones         |02461      |10000|
|34|Jacob Statham     |02623      |15000|

In summary, what we are looking at is somehow joining a query of a given value to a row in a table.总之,我们正在查看以某种方式将给定值的查询连接到表中的一行。

SELECT ID, Title, [Part number], Dcount('*',[Part number]) As Rows FROM [Key]

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

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