Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. insert into mulitiple tables???

insert into mulitiple tables???

Scheduled Pinned Locked Moved Database
databasehelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WetRivrRat
    wrote on last edited by
    #1

    Hey folks, i've run into a sort of brick wall this weekend, and can't find much that will work....here's the issue. i need to do an insert into 2 tables, for an invetory control app, I know this query is wrong, its just a description of what i want to do... Insert into PC (PC_Service, PC_Serial, mon.mon_name, PC_Model, PC_Name, PC_Loc, PC_IP) values(1, 'SerialNujmber','SerialNujmber', 'Model1', 'deviceName', 1, '192.168.0.1') select * from mon inner join pc on pc.pc_id = mon.mon_to_pc where pc.pc_serial = '123456789' or "Insert into Mon ( Mon_loc, Mon_Serial, Mon_serial2, mon_service, mon_to_pc) values ('1', 'KR-032DVX-47602-19Q-ABKQ', 'kermit the frog', '1', (select PC_ID from PC where pc_serial = 'fasdf'))" the first is the overall desire...the second is my last resort.. Any ideas will be helpful thank!!! string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

    L 1 Reply Last reply
    0
    • W WetRivrRat

      Hey folks, i've run into a sort of brick wall this weekend, and can't find much that will work....here's the issue. i need to do an insert into 2 tables, for an invetory control app, I know this query is wrong, its just a description of what i want to do... Insert into PC (PC_Service, PC_Serial, mon.mon_name, PC_Model, PC_Name, PC_Loc, PC_IP) values(1, 'SerialNujmber','SerialNujmber', 'Model1', 'deviceName', 1, '192.168.0.1') select * from mon inner join pc on pc.pc_id = mon.mon_to_pc where pc.pc_serial = '123456789' or "Insert into Mon ( Mon_loc, Mon_Serial, Mon_serial2, mon_service, mon_to_pc) values ('1', 'KR-032DVX-47602-19Q-ABKQ', 'kermit the frog', '1', (select PC_ID from PC where pc_serial = 'fasdf'))" the first is the overall desire...the second is my last resort.. Any ideas will be helpful thank!!! string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

      L Offline
      L Offline
      Luis Alonso Ramos
      wrote on last edited by
      #2

      You could do something like this:

      INSERT INTO Mon (Mon_loc, Mon_Serial, Mon_serial2, mon_service, mon_to_pc)
          (SELECT '1', 'KR-032DVX-47602-19Q-ABKQ', 'kermit the frog', '1', PC_ID
               FROM PC where pc_serial = 'fasdf')
      

      Or if you are using a stored procedure, get the PC_ID into a variable, and use it in the INSERT. The above query will insert multiple records if the SELECT PC_ID FROM PC happens to return multiple records, although by looking at the name of the fields, I wouldn't think so for this particular case. I hope this helps! -- LuisR


      Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

      The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

      W 1 Reply Last reply
      0
      • L Luis Alonso Ramos

        You could do something like this:

        INSERT INTO Mon (Mon_loc, Mon_Serial, Mon_serial2, mon_service, mon_to_pc)
            (SELECT '1', 'KR-032DVX-47602-19Q-ABKQ', 'kermit the frog', '1', PC_ID
                 FROM PC where pc_serial = 'fasdf')
        

        Or if you are using a stored procedure, get the PC_ID into a variable, and use it in the INSERT. The above query will insert multiple records if the SELECT PC_ID FROM PC happens to return multiple records, although by looking at the name of the fields, I wouldn't think so for this particular case. I hope this helps! -- LuisR


        Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

        The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

        W Offline
        W Offline
        WetRivrRat
        wrote on last edited by
        #3

        That Worked!!!! THANKS :-D string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

        L 1 Reply Last reply
        0
        • W WetRivrRat

          That Worked!!!! THANKS :-D string Beautiful; Beautiful = "ignorant"; label1.Text = "The world is full of " + Beautiful +" people."; Why is common sense such an un-common comodity?

          L Offline
          L Offline
          Luis Alonso Ramos
          wrote on last edited by
          #4

          You're welcome! I'm glad I could help! :) -- LuisR


          Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

          The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups