Skip to content
Advertisement

Oracle SQL Inserting multiple rows into a table while referencing 2 FK

I’m trying to insert values id_team_FK and id_location_FK which both come from the same table. For example id_team_FK = 4 and id_location_FK = 150. The problem is, id_team_FK must be a randomly chosen value from team_table ( this works) and I need to know the exact number ( for example 4 ) to realize which id_location_FK is assigned to it ( for example 150 ). How do I make it work ?

Advertisement

Answer

How about CTEs? Select ID_TEAM_FK first, use it to fetch ID_LOCATION_FK, insert the result.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement