SQL Query : Multiple joins [modified]
-
I have 3 tables and need to update the TableC from TableA and TableB TableA OldId NewId TableB OldId OldName OldAddress TableC NewId NewName NewAddress Please help me with the joins. Thanks
------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates
modified on Tuesday, January 19, 2010 5:30 PM
-
I have 3 tables and need to update the TableC from TableA and TableB TableA OldId NewId TableB OldId OldName OldAddress TableC NewId NewName NewAddress Please help me with the joins. Thanks
------------------------------------------------------------ "The only true wisdom is in knowing you know nothing." --Socrates
modified on Tuesday, January 19, 2010 5:30 PM
Hi to get the values for TableC you can use this query:
SELECT TableA.NewId, TableB.OldName, TableB.OldAddress FROM TableA INNER JOIN TableB ON TableA.OldId = TableB.OldId;
If you want to insert the data from this query into tableC it must be something like this (not really sure):
INSERT INTO TableC VALUES (SELECT TableA.NewId, TableB.OldName, TableB.OldAddress FROM TableA INNER JOIN TableB ON TableA.OldId = TableB.OldId);
Hope this helps... Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.