Results 1 to 8 of 8
  1. #1
    dr4ke is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    108

    Select into/update

    Hello,

    I currently use lots of UNION queries in my Database, which is a huge strain on performance and i'm looking to adopt a different method. I would like to create a tempory table, which does two things. Depending on the query I will write, I would like some data to be 'updated' into the table and therefore not delete it. And I would like some data to completely override what is already in there.

    To Summarise...

    This Query (call it 'Query2') will replace anything in 'TemporyTable' with anything that is in 'Query1' once Query2 has been run.



    Code:
     SELECT * INTO TemporaryTable
    FROM Query1;
    What I need is the correct SQL statement to 'add' the information from 'Query1' into 'TemporaryTable' without deleting the current data. I had a go with the below, which simply didn't work. I've used the same naming conventions, as once I understand how it can work I can adopt to what I'm trying to do.

    Code:
     SELECT UPDATE * INTO TemporaryTable
    FROM Query1;
    Attached Files Attached Files

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Please show your tables and relationships. Getting the database designed to support your "business" is key.

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Lots of UNION queries is often a sign of a de-normalized design, but what you're looking for is an append query:

    INSERT INTO TableName(Field1, Field2)
    SELECT Field1, Field2
    FROM OtherTableName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    dr4ke is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    108
    Thanks PBaldy, could you please break this down?

    Is this section the pre-existing table (i.e. 'TemporyTable' in my example)? And would I need to specify what 'fields' to update?

    INSERT INTO TableName(Field1, Field2)
    Is this where the information is being pulled from, into the 'TemporaryTable' ??
    SELECT Field1, Field 2 From OtherTableName

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Here, I looked in help for you.

    Click image for larger version. 

Name:	Append.jpg 
Views:	6 
Size:	107.9 KB 
ID:	8484
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746

  7. #7
    dr4ke is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    108
    Thank you both for your replies. Apologies for the delay in replying, it's been very busy. But this is exactly what I wanted

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. update table from select
    By cthorn112 in forum Queries
    Replies: 3
    Last Post: 06-27-2012, 09:01 AM
  2. Update Column from Multi-select listbox
    By jhargram in forum Forms
    Replies: 4
    Last Post: 02-27-2012, 12:03 PM
  3. Replies: 5
    Last Post: 01-11-2012, 04:26 PM
  4. Replies: 29
    Last Post: 04-18-2011, 07:09 AM
  5. Update query using iif and select
    By josh2009 in forum Queries
    Replies: 1
    Last Post: 04-23-2010, 11:33 PM

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