Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert with an auto-foreign key look up 1

Status
Not open for further replies.

skiflyer

Programmer
Sep 24, 2002
2,213
US
I'm pretty sure this is not possible, and that's fine, but I figure I might as well ask.

Say I have two tables... call the first ini_section, and the second ini_values

They look like
Code:
[b]ini_section[/b]
(pk)ini_section_id
ini_section_name

and
[b]ini_value[/b]
(pk)ini_value_id
(fk)ini_section_id
ini_key
ini_value

Is it possible to somehow do an insert into ini_value with one query if I know the value of ini_section_name, but not ini_section_id... or do I need to look it up first?
 
Code:
insert into ini_value(ini_section,ini_key,ini_value)
select ini_section_id, 'aleb', 4711 -- or whatever 
from ini_section
where ini_name = 'bleb'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top