| Author |
Topic  |
|
|
query12
Starting Member
6 Posts |
Posted - 10/10/2012 : 10:55:33
|
Hi,
What's the reason for choosing Rel1 natural join Rel2 natural join ... natural join Reln over Reln natural join Reln-1 natural join ... natural join Rel1 ? The final result is still the same, only the column order seems to differ.
Thanks. |
Edited by - query12 on 10/10/2012 10:56:05
|
|
|
robvolk
Most Valuable Yak
USA
15566 Posts |
Posted - 10/10/2012 : 11:06:39
|
| As you stated, only the column order would differ. Since SQLTeam is a Microsoft SQL Server website and SQL Server doesn't support natural join, there's not much else we can offer. |
 |
|
|
query12
Starting Member
6 Posts |
Posted - 10/11/2012 : 03:12:49
|
| Ok, what if it's a join on the columns with identical names? Say each 2 relations have one (unique on the set of all possible pairs of relationsm) common column. Then would the order matter? |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1695 Posts |
Posted - 10/11/2012 : 03:32:46
|
quote: Originally posted by query12
Ok, what if it's a join on the columns with identical names? Say each 2 relations have one (unique on the set of all possible pairs of relationsm) common column. Then would the order matter?
In SQL Server,
1) INNER JOIN (or) JOIN keyword is used to combine result set based on common column name
2) Order will depends on common column
For example, Patient Table columns are: Pat_id, name.............. Room Table columns are: Room_id, description, floor etc PatientRoom Table columns are: id, patient_id, Room_id
SELECT ...... FROM PatientRoom pr --------------------------------- Rel1 JOIN Room r ON pr.id = r.Room_id -------------------- Rel2 JOIN Patient p ON pr.patien_id = p.pat_id ------------ Rel3
But you can't change it to
SELECT ...... FROM Patient p ------------------------------------- Rel3 JOIN Room r ----------------------------------------- Rel2 PatientRoom pr -------------------------------------- Rel1
The reason is the Patient and Room tables have no common column....
-- Chandu |
 |
|
|
robvolk
Most Valuable Yak
USA
15566 Posts |
Posted - 10/11/2012 : 07:16:42
|
quote: Ok, what if it's a join on the columns with identical names?
For a natural join, that is implied and required. Duplicate column names are automatically removed from the SELECT list. All other join types have to specify the columns to be joined. |
 |
|
| |
Topic  |
|