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 Problem

Status
Not open for further replies.

OOzy

Programmer
Jul 24, 2000
135
SA
Table: Dept
Dept_ID Dept_Name
{7CFBF07C-0123} Engineering
{864CB2DF-519E} Planning
{344FDBBF-5FDD} Accounting


Table: Employee
Emp_ID FN LN Dept_ID
5562 John Smith ------


I have the above two tables. John Smith is from the Engineering Dept. I tried to insert his info in the Employee but I couldn’t because of the Dept_ID integrity. How can I write an Insert statement to automatically get the Dept_ID from the Dept Table and insert in the Employee table along for the Emp_ID, FN, LN which are known?

Check this if you can't read the tables.
 
insert into Employee
select 5562, John Smith , Dept.Dept_ID from Dept
where Dept_Name='Engineering'

web/sql developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top