insert into mulitiple tables???
-
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? -
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?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 theINSERT
. 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
-
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 theINSERT
. 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
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?
-
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?
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