简体   繁体   中英

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; IE table with the name of [53462] has 10678 rows. 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.

Our tables all have names like 02461, 02623 save for the Key table that has all of the names in it. 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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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