Results 1 to 7 of 7
  1. #1
    egnaro is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    6

    Querying from 2 tables

    I have a SQL question and was hoping someon can help out. I have two tables with the exact same column headings. What is the most efficienc/effective method (if there is one) of querying for rows from the two separate tables into one data set based upon common data within a single column.



    In other words, if tables X and Y both have columns a, b, c and d is it possible to create another table (or query for rows) based on data that appears in, say, column b within both tables?

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Hi egnaro,

    Use a Make Table query to create your "Z" table from the records selected from your "X" table, then use an Append query to add the records from your "Y" table.

    Cheers,

  3. #3
    egnaro is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    6
    Thanks for the response. However, I am still scratching my head a little as my problem is i do not know which of the rows within X and Y will be in the final result...here is an example -
    Table X

  4. #4
    egnaro is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    6
    Thanks for the response. However, I am still scratching my head a little as my problem is i do not know which of the rows within X and Y will be in the final result...here is an example. Assume these are my two tables. What I'd like to be able to do is capture the data that's colored (because apple and banana are the itemss that show up under column a of both tables, whereas orange, grape, kiwi is only in one of the tables and not the other). Thanks again!
    Table XTable YColumn aColumn bColumn aColumn bappleCarappleTruckappleCarappleTruckappleCarbananaTruckorangeCarbananaTruckorangeCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckgrapeCar

  5. #5
    egnaro is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    6
    Table XTable YColumn aColumn bColumn aColumn bappleCarappleTruckappleCarappleTruckappleCarbananaTruckorangeCarbananaTruckorangeCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckgrapeCar

  6. #6
    egnaro is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    6
    Code:
    Table XTable YColumn aColumn bColumn aColumn bappleCarappleTruckappleCarappleTruckappleCarbananaTruckorangeCarbananaTruckorangeCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckbananaCarkiwiTruckgrapeCar

  7. #7
    egnaro is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    6
    Let me try again...

    Table X Table Y
    Column a Column b Column a Column b
    apple Car apple Truck
    apple Car apple Truck
    apple Car banana Truck
    orange Car banana Truck
    orange Car kiwi Truck
    banana Car kiwi Truck
    banana Car kiwi Truck
    banana Car kiwi Truck
    banana Car kiwi Truck
    grape Car

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Querying a database with optuion buttons
    By MattB in forum Access
    Replies: 1
    Last Post: 01-28-2010, 06:43 PM
  2. linking tables to other tables
    By detlion1643 in forum Access
    Replies: 1
    Last Post: 01-25-2010, 12:33 PM
  3. Help Querying series
    By ktmchugh in forum Queries
    Replies: 20
    Last Post: 05-05-2009, 04:31 PM
  4. Querying Queries for Music School
    By jenny_jumps in forum Queries
    Replies: 0
    Last Post: 01-28-2009, 11:46 AM
  5. Joining tables two tables and another table that is not
    By DevintheDude in forum Database Design
    Replies: 0
    Last Post: 09-12-2007, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums