Thread: Linking Problem
View Single Post
  #3  
Old June 12th, 2007, 09:33 AM posted to microsoft.public.access.tablesdbdesign
Jamie Collins[_2_]
external usenet poster
 
Posts: 118
Default Linking Problem

On Jun 11, 6:28 pm, Chinny03
wrote:
I have a database with 12 tables. I want to do a simple query where I would
get the count of three different tables.

Count(TableA)
Count(TableB)
Count(TableC)

All three tables have the same primary key.


The hard way (a.k.a. roll your own):

SELECT COUNT(ID) AS CARDINALITY, 'TableA' AS TABLE_NAME
FROM TableA
UNION ALL
SELECT COUNT(ID), 'TableB'
FROM TableB
UNION ALL
SELECT COUNT(ID), 'TableC'
FROM TableC;

An easier way: use the SCHEMA_CATALOG (a.k.a don't reinvent the
wheel):

Set rs = CurrentProject.Connection.OpenSchema(adSchemaStati stics)
rs.Filter = "TABLE_NAME = 'TableA' OR TABLE_NAME = 'TableB' OR
TABLE_NAME = 'TableC'"
? rs.GetString
TableA 1
TableB 3
TableC 0

Jamie.

--