Results 1 to 4 of 4
  1. #1
    Noob's Avatar
    Noob is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    36

    Question Help Understanding what this Query is doing [INSERT INTO, SELECT , FROM, INNER JOIN, ON, WHERE]

    Hi Everybody,

    I dont understand this Query fully & was hoping someone would be kind &help me get my brain wrapped around what is going on.


    Code:
    INSERT     INTO [MADE XYZ_PRCNG1]
                 ( 
                            A_FIELD_NUM, 
                            A_FIELD_TY_CD, 
                            RSN_CD, 
                            A_FIELD_PRC_EFF_DT, 
                            A_FIELD_PRC_END_DT, 
                            A_FIELD_PRC_AMT, 
                            CURR_ROW_IND, 
                            PRCNG_SRC_CD 
                ) 
    SELECT         XYZ_PRCNG_H.A_FIELD_NUM, 
               XYZ_PRCNG_H.A_FIELD_TY_CD, 
               XYZ_PRCNG_H.RSN_CD, 
               XYZ_PRCNG_H.A_FIELD_PRC_EFF_DT, 
               XYZ_PRCNG_H.A_FIELD_PRC_END_DT, 
               XYZ_PRCNG_H.A_FIELD_PRC_AMT, 
               XYZ_PRCNG_H.CURR_ROW_IND, 
               XYZ_PRCNG_H.PRCNG_SRC_CD 
    FROM       XYZ_PRCNG_H 
    INNER JOIN [MADE Distinct A_FIELDs] 
    ON         XYZ_PRCNG_H.A_FIELD_NUM = [MADE Distinct A_FIELDs].[A_FIELD Code] 
    WHERE      ((( 
                                                XYZ_PRCNG_H.A_FIELD_TY_CD)="01") 
               AND        (( 
                                                XYZ_PRCNG_H.RSN_CD)<>"04")));
    Ok so what I understand is that we are doing a INSERT ONTO the MADE XYZ_PRCNG1 TABLE. We are going to be INSERTING ONTO the 8 like FIELDs. Thats all I got. The SELECT FROM INNER JOIN part is throwing me for a loop. Is that a 9th FIELD that is going to be INSERTED INTO?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    the INSERT query adds records to a table.
    THIS query is using another query to add the records.
    The 2nd query joins 2 tables together.

  3. #3
    Noob's Avatar
    Noob is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    36
    Wow I didnt know that could be done all in 1 SQL statement. Thanks a lot @ranman256. This seems way more advanced than whats covered in any of the learning materials I have got my hands on. If anyone knows of a book that covers advanced SQL queries PLEASE mention it. Thanks in advance.

  4. #4
    Noob's Avatar
    Noob is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2016
    Posts
    36
    I found this: Subquery Fundamentals

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

Similar Threads

  1. Insert value and select ID
    By FinalByte in forum Access
    Replies: 2
    Last Post: 10-31-2013, 08:53 AM
  2. Replies: 2
    Last Post: 08-26-2013, 11:29 AM
  3. Replies: 2
    Last Post: 11-11-2012, 09:02 PM
  4. when (select statement within inner join should be used)?
    By learning_graccess in forum Programming
    Replies: 1
    Last Post: 05-17-2012, 01:54 PM
  5. INSERT with SELECT query.
    By goodguy in forum Queries
    Replies: 8
    Last Post: 09-23-2011, 10:38 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