Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Append SQL (Access97 )

    Hi All,

    Is it possible to combine the following SQL so that SQL1 use the results of SQL2? And if so, what syntax would I use?

    'SQL1
    INSERT INTO Table2 (Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field)
    SELECT Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9

    'SQL2
    SELECT Table1.FIELD1, Table1.FIELD2, Sum(Table1.FIELD3) AS SumOfFIELD3, Sum(Table1.FIELD4) AS SumOfFIELD4, Sum(Table1.FIELD5) AS SumOfFIELD5, Table1.FIELD6, Table1.FIELD7, Table1.FIELD8, Table1.FIELD9
    FROM Table1

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Append SQL (Access97 )

    Since I'm assuming your fields line up from SQL2 to SQL1, you cand do this:

    INSERT INTO Table2 (Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field)
    SELECT * from SQL2
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Append SQL (Access97 )

    Thanks Mark.

    SQL2 isn't a saved query but you reply gave me an idea.

    I replaced the SELECT statement from SQL1 with the SQL2 SELECT statement and the correct results were returned.

    INSERT INTO Table2 (Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field)
    SELECT Table1.FIELD1, Table1.FIELD2, Sum(Table1.FIELD3) AS SumOfFIELD3, Sum(Table1.FIELD4) AS
    SumOfFIELD4, Sum(Table1.FIELD5) AS SumOfFIELD5, Table1.FIELD6, Table1.FIELD7, Table1.FIELD8,
    Table1.FIELD9
    FROM Table1

    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •