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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT HELP

Status
Not open for further replies.

rbauerle

Programmer
Oct 16, 2001
48
BR
I need to insert a name and another's table id into a table. For example:
name = John
id = table2.id
The problem is I don't have this id value. I would have to take it from a Select an use it in an Insert at the same time I insert a common value, so that insert..select doesn't do exactly what i need.
That would be something like this:
INSERT INTO table1 (name, id2)VALUES('John', SELECT id FROM table2 WHERE name='t2name')

Is there anything that would do this???

Thanks a lot.
 
you were so close!

INSERT INTO table1 (name, id2)
SELECT 'John', id
FROM table2
WHERE name='t2name'

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top