Using the Union

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • farriswheel
    New Member
    • Sep 2006
    • 8

    #1

    Using the Union

    Hello All,
    I'm having trouble using a union function with "insert into" function.
    Maybe what I'm trying to do is not possible
    Thanx for the help!
    Farris

    INSERT INTO [temp order_tbl] ( [part no], [part type], cost)
    SELECT [model no], productdescript ion, unitprice
    FROM model_tbl
    WHERE [model no] = (forms![main_frm]![computer_lbx].Value)

    UNION

    INSERT INTO [temp order_tbl] ( [part no], [part type], cost)
    SELECT [display no], productdescript ion, unitprice
    FROM display_tbl
    WHERE [display no] = (forms![display_frm]![displayList_lbx].Value);
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    Try this:

    INSERT INTO [temp order_tbl] ( [part no], [part type], cost)
    SELECT [model no], productdescript ion, unitprice
    FROM model_tbl
    WHERE [model no] = (forms![main_frm]![computer_lbx].Value)
    UNION
    SELECT [display no], productdescript ion, unitprice
    FROM display_tbl
    WHERE [display no] = (forms![display_frm]![displayList_lbx].Value);

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by mmccarthy
      Try this:
      ...
      I'm really curious about this. If you insert into a UNION query, how does Access know which of the "unioned" tables to put the record into?

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        You can't insert into a UNION.

        We're trying to Insert into a table the results of a UNION.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by mmccarthy
          You can't insert into a UNION.
          We're trying to Insert into a table the results of a UNION.
          Ah! Sorry about that, I muddled up the syntax. Guess I need to study up on my SQL - no real surprise there.

          Comment

          • MMcCarthy
            Recognized Expert MVP
            • Aug 2006
            • 14387

            #6
            No need to be sorry

            I still mess up badly on SQL sometimes. It can be a nightmare of logic.

            Comment

            Working...