Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 23rd, 2004, 03:41 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple self-join

I have a table with this structure and content

IdA Name FK_Ida
1 A 1
2 Aa 1
3 Ab 1
4 Aaa 2
5 Abb 2
6 Acc 3
7 Add 3

I want to use a SQL-query to get this result

A Aa Aaa
A Aa Abb
A Ab Acc
A Ab Add


I've tryed this:


SELECT a.Name as ParentCategory, b.Name
FROM table as a right JOIN table AS b
  ON a.ida = b.fk_ida


Select a.Name as ParentCategory, b.Name
From table a, table b
Where a.ida = b.fk_ida


But both of them give me just the "top level" and "sub level" but not the "sub sub level"

Can someone help me with a correct SQL-question to get all of the levels in a table like that?

Thank you

//Matte

Reply With Quote
  #2 (permalink)  
Old April 23rd, 2004, 04:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

It sounds like you have the same problem as this post: http://p2p.wrox.com/topic.asp?TOPIC_ID=7599

does that help?
Reply With Quote
  #3 (permalink)  
Old April 23rd, 2004, 05:20 AM
Authorized User
 
Join Date: Apr 2004
Location: , , Ireland.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Select a.Name , b.Name , c.Name
From table a, table b , table c
Where a.ida = b.fk_ida
AND b.ida = c.fk_ida

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Self Join w/Dynamic Level Hierarchy LiamLiamLiam SQL Language 0 August 17th, 2007 10:21 AM
Inner join query with multiple tables.. rupen Access 2 April 9th, 2007 11:16 AM
Insert multiple records in a Inner Join Table rylemer Access 1 August 22nd, 2004 07:44 AM
Insert multiple records in a Inner Join Table rylemer Access VBA 0 July 19th, 2004 03:54 PM
Inner Join multiple tables qwprince Classic ASP Databases 5 July 23rd, 2003 02:33 PM



All times are GMT -4. The time now is 05:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.