Ask Experts Questions for FREE Help !
Ask
    LaneyLou's Avatar
    LaneyLou Posts: 8, Reputation: 1
    New Member
     
    #1

    Dec 11, 2008, 11:36 AM
    10 Tables combined
    I have 10 tables that all have the same columns with the same names.
    I have created a new table that has all those same field names.
    I want the rows in all 10 tables to pull into one table or query. Would prefer a table.

    I would just combine all the tables but they're linked from other databases and other departments have to use those individual tables to make their forms and stuff work.

    I also have another table that has the same fields but also has more fields. I would like to JUST pull in the like fields so that data can be displayed as well.
    StaticFX's Avatar
    StaticFX Posts: 943, Reputation: 74
    Senior Member
     
    #2

    Dec 11, 2008, 11:57 AM

    I will use letters for fields names (to make it easy)

    Create a new query (Change the query type to UNION Query)

    SELECT A,B,C,D,E,F,G FROM TABLE1
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE2
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE3
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE4
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE5
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE6
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE7
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE8
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE9
    UNION ALL
    SELECT A,B,C,D,E,F,G FROM TABLE10


    Save it
    Then create another query (Set it as a make table)
    Use the Unionquery as the source

    Make sure you use the union ALL (otherwise it will combine rows that match)
    LaneyLou's Avatar
    LaneyLou Posts: 8, Reputation: 1
    New Member
     
    #3

    Dec 11, 2008, 12:17 PM
    I don't show any options to set it as a make table or to use a unionquery. I'm on Access 2003 does that make a difference?
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Dec 11, 2008, 12:23 PM
    Since you have to keep the individual tables separate, I agree a Union query is the best solution. You do NOT want to duplicate data.

    You might have to add a field to identify the source table unless there is something else that does that. For example:

    SELECT A,B,C,D,E,F,G, "table1" As Tablename FROM TABLE1
    UNION ALL
    SELECT A,B,C,D,E,F,G, "table2" As Tablename FROM TABLE2

    etc.

    To enter a union query you have to actually type in the code in SQL mode. Open a new query in design mode then select SQL view
    StaticFX's Avatar
    StaticFX Posts: 943, Reputation: 74
    Senior Member
     
    #5

    Dec 11, 2008, 12:28 PM

    Switch to Queries
    Select New Query > Design View
    Close the show table window
    In the Query Menu Select SQL Specific > Union Query

    It does the same as just clicking the "view sql"

    Then as Scott Said... you have to type in the sql.
    If there is a risk of duplicated data, use scott's example and add a column to show which table it came from.
    LaneyLou's Avatar
    LaneyLou Posts: 8, Reputation: 1
    New Member
     
    #6

    Dec 12, 2008, 02:09 PM
    Took care of all that. Moved it all over to test with the guys, they said it's good. I moved it to Production a few minutes ago. Yeah!

    Only bad thing that happened is when I moved my form over to read the new database some how the save and enter new part number button went pffffffft 'cause it won't work now. Trying to figure that out and I'm all good. Right now they're having to open the form again to pull a new part number hehe but they're cool with that. :)

    Hopefully I'll get this sucker figured out. UGH :(
    LaneyLou's Avatar
    LaneyLou Posts: 8, Reputation: 1
    New Member
     
    #7

    Dec 12, 2008, 02:10 PM
    Quote Originally Posted by StaticFX View Post
    Switch to Queries
    Select New Query > Design View
    Close the show table window
    in the Query Menu Select SQL Specific > Union Query

    It does the same as just clicking the "view sql"

    then as Scott Said... you have to type in the sql.
    If there is a risk of duplicated data, use scott's example and add a column to show which table it came from.
    I just went into the individual tables and put a new column in and just pasted in the name of the database it came from then set it to auto populate that same word when new ones are entered. There are no duplicates and it's working great. :)

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

AOL and Outlook Express combined [ 4 Answers ]

I am using Vist:confused:a, and I prefer my AOL as my email account.. but, somehow each email that I receive through AOL is deleted then appears in the Outlook Express email.. I am not signed up for Outlook, so the emails that are there, I can not forward or reply. How do I change the way that...

Combined inequalities [ 1 Answers ]

1)d - 1 > -3 and d + 2 < 5 2) -3k + 7 > -5 and -7k + 5 < -2 3) -5 < 2y - 3 < 23 4) x - 4 < 5 or x + 2 > 15 5) 5x - 4 > 6 or -4x + 5 > 1

Combined medicine [ 1 Answers ]

Can you take Sudafed PE and Motrin together?

Combined inequalities [ 1 Answers ]

1. 2x > -6 and x -4 _<_to 3


View more questions Search