Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-20 : 21:51:27
|
| Hello,I am making a derived table of the form (select col1, col2 from tablea,tableb, tablecwhere table1.foreign key = table2.pkand table2.pk = table3.fk)) ajoin table 3join table 2How would I select the key for the derived table?What should we keep in mind while selecting the key for the derived table?Thank you! |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-09-20 : 23:30:27
|
| Not sure what you mean. Derived tables can not have a primary key or constraints or anything like that. Of course, as the developer and the person who understands your data, you should be aware of what would be the logical key - ie what columns represent a unique row.Also, use the ANSI JOIN syntax. ie: INNER JOIN, LEFT OUTER JOIN, etc. The comma seperated list of tables is old school and won't even be supported later.Be One with the OptimizerTG |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-21 : 01:28:22
|
quote: Originally posted by sqlclarify Hello,I am making a derived table of the form (select col1, col2 from tablea,tableb, tablecwhere table1.foreign key = table2.pkand table2.pk = table3.fk)) ajoin table 3join table 2How would I select the key for the derived table?What should we keep in mind while selecting the key for the derived table?Thank you!
the key column by which you want to join the derived table to other table(s) should be included in select list of derived table.Regarding what column to be chosen as key, it purely based on how rest of query is related to derived table. |
 |
|
|
|
|
|
|
|