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

Three Table Join?

Status
Not open for further replies.
Apr 3, 2003
180
US
Can someone please help with a multi table issue I am having? I need to insert info from table_b into table_c but only if table_c and table_a have a matching user_id. table_b and table_a have a matching employee_id. table_a also has a user_id column (not in table_b) that is the same in table_c. I need to insert info from table_b into table_c but only if there is a match between table_b employee_id and table_a employee_id and table_a user_id and table_c user_id.
All of these table are in the same database on the same box. table_a and table_c are used by the same application and table_b by a diffrent one. I can not modify table_a and table_c because the application is dependant on thier current structure. I can modify table_b any way nesecerry.
Also, I curently pass data from table_a to table_b with an INSERT INTO statment dependant on the employee_id, but now need to pass diffrent data from table_b to table_c. Thanks for your effort.

"I hear and I forget. I see and I remember. I do and I understand."
- Confucius (551 BC - 479)
 
You can insert from a result set returned from a select queries
INSERT INTO TABLE_C
SELECT
USER_ID
,EMP_ID
,....
FROM
TABLE_b
JOIN TABLE_c ON MATCHINGCOLINTABLE_C = MATCHINGCOLINTABLE_a
JOIN
-----
Hope this helps.

Thanks and Regards,
Siva


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top