Juan Ocasio
asked on
Complex SQL statement (at least for me) to insert values into a table using other tables in my database
Hello all:
This is probably very easy, but I do not know how to accomplish the task. I three tables. One table is a temp table that was loaded from an excel file. The other two tables are a header table and detail table.'
So what I have to do is load the two tables from the temp table (there was really 2 temp tables, but I've already loaded that into the header table in my database).
I need to do something like:
INSERT INTO detailTable (Uniqueid, Address, State)
and here is where I'm not sure about the select statement.
I have to get the h.uniqueid from headertable h inner join temptable t on h.HeaderID = t.HeaderID
and I also need to make sure all of the results in the from are only in the tempdetail
Any help would be greatly appreciated
This is probably very easy, but I do not know how to accomplish the task. I three tables. One table is a temp table that was loaded from an excel file. The other two tables are a header table and detail table.'
So what I have to do is load the two tables from the temp table (there was really 2 temp tables, but I've already loaded that into the header table in my database).
I need to do something like:
INSERT INTO detailTable (Uniqueid, Address, State)
and here is where I'm not sure about the select statement.
I have to get the h.uniqueid from headertable h inner join temptable t on h.HeaderID = t.HeaderID
and I also need to make sure all of the results in the from are only in the tempdetail
Any help would be greatly appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome.. and thanks for posting such a clear question. Having the table layout and expected results always makes it much easier to help :)
ASKER
Thanks for your help!