multiple inserts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jas2803
    New Member
    • Oct 2007
    • 30

    multiple inserts

    Hello,
    I have two tables,
    Clients: [Client ID] [Location].....
    Followup: [Client ID] [Location] [Date] [Results]
    I would like to mass update by inserting new records in followup based on [Location] in Clients. That is, if Location is = "Mumbai" insert a new record into Followup, containing each Client ID and Location in addition to a [Date] and [Results], the date and results will be the same for each. So my end result in Followup will be like the following

    [ Client ID] [Location][Date][Results]
    (01), (Mumbai), (2008-03-04), (Positive)
    (07), (Mumbai), (2008-03-04), (Positive)
    (11), (Mumbai), (2008-03-04), (Positive)
    (15), (Mumbai), (2008-03-04), (Positive)
    (22), (Mumbai), (2008-03-04), (Positive)
    (22), (Mumbai), (2008-03-04), (Positive)
    (24), (Mumbai), (2008-03-04), (Positive)
    (27), (Mumbai), (2008-03-04), (Positive)
    (31), (Mumbai), (2008-03-04), (Positive)
    (38), (Mumbai), (2008-03-04), (Positive)
    (50), (Mumbai), (2008-03-04), (Positive)


    Any ideas?
    Thanks
    JAS
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by jas2803
    Hello,
    I have two tables,
    Clients: [Client ID] [Location].....
    Followup: [Client ID] [Location] [Date] [Results]
    I would like to mass update by inserting new records in followup based on [Location] in Clients. That is, if Location is = "Mumbai" insert a new record into Followup, containing each Client ID and Location in addition to a [Date] and [Results], the date and results will be the same for each. So my end result in Followup will be like the following

    [ Client ID] [Location][Date][Results]
    (01), (Mumbai), (2008-03-04), (Positive)
    (07), (Mumbai), (2008-03-04), (Positive)
    (11), (Mumbai), (2008-03-04), (Positive)
    (15), (Mumbai), (2008-03-04), (Positive)
    (22), (Mumbai), (2008-03-04), (Positive)
    (22), (Mumbai), (2008-03-04), (Positive)
    (24), (Mumbai), (2008-03-04), (Positive)
    (27), (Mumbai), (2008-03-04), (Positive)
    (31), (Mumbai), (2008-03-04), (Positive)
    (38), (Mumbai), (2008-03-04), (Positive)
    (50), (Mumbai), (2008-03-04), (Positive)


    Any ideas?
    Thanks
    JAS
    Are you looking at something like:

    [code=sql]

    INSERT INTO followup SELECT clientid,locati on,'2008-03-04','Positive' FROM client WHERE location = 'Mumbai'

    [/code]

    Comment

    • jas2803
      New Member
      • Oct 2007
      • 30

      #3
      wow, so simple, but not very intuitive....wo rked like a charm.
      I looked but all I could find was how to select and insert the selected column data only.
      Thanks
      Last edited by jas2803; Mar 4 '08, 07:15 PM. Reason: added comment

      Comment

      • amitpatel66
        Recognized Expert Top Contributor
        • Mar 2007
        • 2358

        #4
        Originally posted by jas2803
        wow, so simple, but not very intuitive....wo rked like a charm.
        I looked but all I could find was how to select and insert the selected column data only.
        Thanks
        You are Welcome Jas2803. Do post back in case of any further issues!!

        Comment

        Working...