Need help with insert query ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick

    #1

    Need help with insert query ?

    Deear All,
    I would be thankful if you could help me with the following query.

    I have two tables TableA and TableB

    TableA
    Name: David
    Address: 123 West Side
    City: New York

    TableB
    Name: David
    Address: 123 West Side
    Profession: Engineer

    I need to Insert the data from TableB to TableA if the Address matches

    I want to get rid of TableB so I want to merge the data from second and add a
    Profession in Table A

    So after merging the Table A would be

    TableA
    Name: David
    Address: 123 West Side
    City: New York
    Profession: Engineer

    I would appreciate your help and Thanks in Advance

    Nick
  • PC Datasheet

    #2
    Re: Need help with insert query ?

    The BIG problem is that you need a way to identify which record in TableA to add
    Engineer to! If you go solely on Name, there may be records in TableA that have
    the same name but not necessarily duplicates. The best you're going to do is to
    use both the Name and Address fields and making the assumption (keeping in mind
    the definition of what assumption is) that for the same person, his Name and
    Address is entered in to both tables EXACTLY the same way. Given this
    ass-umption, create a new field in TableA called Profession. Next include both
    tables in a query. Join the Name fields in both tables and join the Address
    fields in both tables. Pull down the Profession field from TableA. Change the
    query to an Update Query by clicking on the query type button in the toolbar at
    the top of the screen. In the query grid where it says Update To under
    Profession put:
    TableB.Professi on.

    Click on the red exclamation point in the toolbar at the top of the screen and
    depending on the validity of your assumption you will get what you want.


    --
    PC Datasheet
    Your Resource For Help With Access, Excel And Word Applications



    "Nick" <n.shah21@veriz on.net> wrote in message
    news:d669575d.0 310121400.6bb14 61f@posting.goo gle.com...[color=blue]
    > Deear All,
    > I would be thankful if you could help me with the following query.
    >
    > I have two tables TableA and TableB
    >
    > TableA
    > Name: David
    > Address: 123 West Side
    > City: New York
    >
    > TableB
    > Name: David
    > Address: 123 West Side
    > Profession: Engineer
    >
    > I need to Insert the data from TableB to TableA if the Address matches
    >
    > I want to get rid of TableB so I want to merge the data from second and add a
    > Profession in Table A
    >
    > So after merging the Table A would be
    >
    > TableA
    > Name: David
    > Address: 123 West Side
    > City: New York
    > Profession: Engineer
    >
    > I would appreciate your help and Thanks in Advance
    >
    > Nick[/color]


    Comment

    Working...