Listing all records for same field from multiple tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I want to list all the records of a particular field from all tables in my
database. The field has the same name in all the tables. Ideally I would like
one long list of the records. How can I do this?

Thanks,

Richard
 
SELECT YourFieldName FROM YourFirstTableName
UNION ALL SELECT YourFieldName FROM YourSecondTableName
UNION ALL SELECT YourFieldName FROM YourThirdTableName

Etc. for each table.
 
Thanks, that's great.

Now I have a list, how can I extract a list of duplicate values?

Richard
 
I'll have to use an unrelated table for this example, as I don't have a
suitable union query available, but the idea is that you would use this
against the union query from my previous post ...

SELECT Count(Table2.Name) AS CountOfName, Table2.Name
FROM Table2
GROUP BY Table2.Name
HAVING (((Count(Table2.Name))>1));
 
Assuming you saved that union query as, say, qryMyUnionQuery, try:

SELECT YourFieldName
FROM qryMyUnionQuery
GROUP BY YourFieldName
HAVING Count(*) > 1
 
Thanks, I tried this and it says my query is to complex (there are 2161
records that it is searching through). Any other ways that I could make it
work?

Richard
 
You sure you typed all the names correctly? That error message will
sometimes appear if Access can't figure out the query.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top