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 |
|
rluxmi
Starting Member
6 Posts |
Posted - 2009-05-14 : 14:48:06
|
| How to re-write this self-join queries by using the sub-query Structure (without using the CONNECT BY clause)?1. SELECT f1.child as parent, f2.child FROM FamilyTree f1, FamilyTree f2 WHERE f1.child = f2.parentAns. So far I have SELECT * from familytree where parent is not null; but this is not listing it alphabetically. I tried using order by but it gives an error.2.SELECT f1.child as grandparent, f3.child as grandchild FROM FamilyTree f1, FamilyTree f2, FamilyTree f3 WHERE f1.child = f2.parent AND f2.child = f3.parentAns. So far I have SELECT f1.child as grandparent, f3.child as grandchild FROM FamilyTree f1, FamilyTree f2, FamilyTree f3 WHERE f1.child, f3.child, f2.parent is not null; |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-05-14 : 15:31:12
|
CONNECT BY is not a Microsoft SQL Server statement.Are you by chance using Oracle (given the syntax above for WHERE clause)? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
rluxmi
Starting Member
6 Posts |
Posted - 2009-05-14 : 15:37:56
|
| Is there any other form of writing this query which would give the same result? |
 |
|
|
|
|
|