Looking for a recursive answer using a intersection table. Possible CTE? Other method?

Hello all,
This is my first time on the forums, so please bear with me.  Im also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum.
I have 3 tables, a user table, a group table and a membership table.
Say:
user_table
+-------------------+
| user_PK |
| Id |
| Name |
| Description |
+-------------------+
Group_table
+-------------------+
| group_PK |
| Id |
| Name |
| Description |
+-------------------+
Group_members
+----------------------+
| group_members_PK |
| Group_ID |
| Member_ID |
| Member_type |
+----------------------+
The group_ID is linked to the Group_table.ID and the Member_ID can be either linked back to the group_table or user_table depending on the value of member_type.  
It is possible to have nested groups, and each level of nesting can have users as well not just nested groups.  Sort of how the windows group nesting model works.
I would like to end up with being able to have output that lists only users, their descriptions and their nested group path if any.
If you need more clarification please let me know.   I know this maybe a simple thing, but Im unsure how to do it.  Thanks in advance.

>> This is my first time on the forums, so please bear with me.  I am also a somewhat novice SQL coder but I have a question that I feel might be best answered my the more advanced folks on this forum. <<
Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. There is no generic “id”, “name, etc. in RDBMS. Tables have to have a key,
but we do not put “_pk” on the name. Read a copy of https://www.simple-talk.com/books/sql-books/119-sql-code-smells/ so you will stop tibbling and other bad practices.  
You should follow ISO-8601 rules for displaying temporal data. We need to know the data types, keys and constraints on the table. 
Avoid dialect in favor of ANSI/ISO Standard SQL. And do not draw ASCII pictures! They do not compile. 
>>The group_id is linked [sic] to the group_table.id [sic] And the member_id can be either linked [sic] back to the group_table or user_table depending on the value of member_type.  <<
RDBMS has no links; that was in network databases in the 1970's. No wonder you want to use recursive CTEs; they are cursors 
>> It is possible to have nested groups, and each level of nesting can have users as well not just nested groups.  Sort Of how the windows group nesting model works. <<
Then you should use a nested sets model.  Since you did not post sample data, DDL  or correct specs, Google it.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • Looking for interMedia web sites using text retrieval

    I'm looking for web sites which use interMedia to support their site search function. My goal is to evaluate intermMedia for use as a full text search engine.
    I'm particularly interested in sites which use the thesaurus features.
    Thanks.

    There are many sites on the Internet that use interMedia Text for site search and for catalog search.
    While we don't track which Oracle customers use particular components of the database such as interMedia, here are a few good examples for you to try :-
    oracle.com - of course
    myCNN.com - CNN's personalized news service
    bol.com - on-line books, music etc.
    - Steve B.
    null

  • I cannot update the iphoto ap on my mac os x because it looks for the ID I used when buying it and I forget the password to that

    I cannot update the iphoto ap on my mac os x because it looks for the ID I used when buying it and I forget the password to that email.
    The emails is obsolete so I cannot get the password from the service provider.
    I have another Apple ID and password which I use - but it won't let me update the iPhoto I bought with THIS cMac

    Content and Apple IDs -
    Content is forever tied to the Apple ID that bought it. Apple does not transfer content from one Apple ID to another. Apple does not merge Apple IDs. You will never be able to access your content bought with one Apple ID with a new Apple ID.

  • Looking for a simple answer ........ without the ...

    looking for a simple answer  ........why is it more difficult for skype to connect than before . It fails to ring most times and your never sure if it is just slow or did not dial in the first place???  and is there any way to disable the leave a message feature ??? I am afraid soon it will be like most wondows applications where you will need endless updates and patches just to keep it running ..... Why is it that everyone is trying to fix everthing when it isnt broken.

    WTF? I'm sure you can find plenty of examples on google. It's on you to take the time to go through them, study them, and, if you still don't understand something, post a clear, concrete question that indicates what you read and what you didn't understand about it.
    As is, you're essentially treating folks here as your research flunkies and saying, "Give me an example that's better than all the ones already easily available to me. Read my mind to know why I didn't like them."

  • What to Look For when Buying a Used Storm to activate on Verizon Pre-Pay

    Hi, I am looking to buy a Storm 9550 refurbished for use on Verizon Pre-Pay and am just wondering what all I need to look for.
    Would something like this work:
    http://www.ebay.com/itm/Great-BlackBerry-Storm2-9550-2GB-Black-Verizon-Smartphone-WIFI-GSM-Phone-/181217767463?pt=Cell_Phones&hash=item2a316bb027
    Or is it more complicated than just finding a Verizon-branded phone?

    The lugs that hold the base onto the phone are not strong enough and the base often needs to be replaced. Give the base (the bit with the button on it) a tug to see whether it's broken.

  • What to look for when buying a used N8?

    I am buying a used N8, so I want to know if there is something specific to look for or just general things?

    The lugs that hold the base onto the phone are not strong enough and the base often needs to be replaced. Give the base (the bit with the button on it) a tug to see whether it's broken.

  • HT1338 my mac book pro is constantly "looking for networks" while connected using my home network and other wifi systems. how can i stop it?

    Why is my Mac Book constantly "looking for networks" while i am using wifi?

    If it is constantly searching for networks every five seconds or so, then it is the bluetooth - wifi problem discussed on other threads. I find that system preferences > network and clicking at the bottom on the 'Show wi-fi status in menu bar' button to switch it off, and then back onto the menu bar, solves the problem. Sometimes on waking I lose wi-fi completely and have to reload, but that's infrequent.
    Hopefully Apple will come up with a solution soon.

  • Looking for simple search example using SELECT

    Can anyone link me to an example of how to create a basic search page where the search criteria is selected in a drop-down list (<SELECT> in HTML)?
    Here's where I'm coming from so you have a better idea of what I'm trying to do. I've created a search page by creating a method in my App Module java class using setWhereClause(), then dropped my view onto my web page as a read-only table, and finally dropped the method and parameter as a command button and input text field, respectively. This works fine, but I'd like to replace the input text field with a select box so that the users will not have to type in their search criteria. I'd like to populate the drop-down with data from a table, which will then be sent as the argument for the method.
    I can create a ViewObject that contains the data I need, but I'm not sure where to go from there. I don't know how to create the drop-down list or connect the command button to the list. (Ultimately, I'd like to have the search text submitted when the drop-down changes, but I'll settle for pressing the button for now). I've fooled with using the LOV component, but without any luck.
    Step-by-step would be great, but if you can point me to an example, some documentation, etc., that would be great too.
    Thanks,
    Andy

    Excellent - Thanks for the link to the sample code page. I thought I had seen all the tutorials, etc. but for some reason never came across this page. The example you cited looks like it's just what I'm looking for.
    (Edit - For anyone who's interested, here's a step-by-step for creating a databound drop down list:
    http://www.oracle.com/technology/products/jdev/tips/mills/databound_lists.html )
    Andy

  • What to look for when buying a used MacBook Pro? Tips

    Here to acquire a few tips on purchasing a used Macbook Pro. I am not graced with an Apple Store in my area, so I must rely on my own sub par geek wit and with the help of yours.
    Tips I know.
    Checking Battery Cycles and mAh capacity.
    Looking for third party applications.
    Request the original StartUp/Install Disks.
    Checking memory ratios...

    Shop your local and nearby Craigslist websites, starting with:
    http://tampa.craigslist.org/
    Read this excellent post by frequent contributor JasonFear about buying and selling through Craigslist:
    http://discussions.apple.com/click.jspa?searchID=-1&messageID=9958349
    Avoid Ebay.
    If third-party applications or other software are included, they add nothing at all to the value of the machine unless you are given the original installer discs for them. Otherwise, they are just pirated software that you can't reinstall if you ever need to.
    Message was edited by: eww

  • Looking for good easy to use inexpensive tuner

    Hi,
    I am looking for a good, easy to use, inexpensive tuner. Not one you use in a rack or on a pedal, but one you use on the computer. I looked and there are a ton out there so I figured I would look for recommendations here.
    I do not like the way GBs works. It fluctuates too much as the note decays and drives me nuts. I want a simple one, that works great. (If it has a feature that helps in tuning a 12 string, than thats a plus, but not a deal breaker). Simple and accurate is most important.
    Lastly I noticed some they sell are AU and some are stand alone. Is one better than the other?
    Thanks,
    Paul

    Strangedogs,
    Thanks for the link but if you read the review of it on the site, it is terrible. The users on VT hated it. It got 1 star out of 5. I was looking for a recommendation of one that someone has actually "used" themselves and likes it from experience using it.
    There was a link that someone posted there for a free tuner from emagic that they said is great, but all the links I found with google run to a dead end unfortunately.
    Paul
    BTW: boy do those 12 strings take forever to tune. I was jamming with a friend over new years weekend and it took him forever to tune up, (and he has an excellent ear).

  • Looking for the definitive answer on what Camcorder to buy!

    Hello folks, I could really use your help.
    I'm an avid Mac user in the graphic design world, and have an iMac as a home machine. I'm going out next week to buy a Digital Camcorder so that I can begin working with home movies of my family and such. I'm new to the camcorder world, and have discovered a wealth of information regarding the cameras available...and as a result am more confused than ever.
    What I'm looking for is a Camcorder with a price tag not much over $600 that will allow me to shoot good indoor & outdoor video of my family and children, and that is easilly compatible with my iMac and the newest version of iLife on the market. I want to create DVD's from this, and store our home movies this way.
    Can anyone tell me what camera fits all of these requirements? I'm looking at the Canon Elura 80 which I've found good things about, but would really like to hear from some of you with experience on the subject.
    Any input or suggestions would be tremendously appreciated. My thanks in advance.
    Chris Zimmerman

    You may want to join this thread:
    DGIL, "What video camera to purchase??", 11:05am Nov 7, 2005 CDT
    Although, that poster's budget is higher than yours, there are some good advive.

  • Looking for good book on using DSLR for shooting video

    I recently purchased a new Canon t3i DSLR. I've been watching videos on YouTube and it seems like this camera is capable of taking great HD video. My test videos look nothing like these examples. I am looking for a good resource that will teach me what settings to use, especially manual settings for shooting videos. Of course it would be great to find something specific to my camera, but I'm sure that the techniques will apply to most DSLRs.
    Thanks

    This website is very useful
    http://nofilmschool.com/

  • Looking for Analog Out example using DMA and C++; cannot find sample "GenMultVoltUpdates_SWTimed"

    Looking for example for Analog Out to multiple channels using DMA and C++.  Found reference to sample "GenMultVoltUpdates_SWTimed" which I do not have and cannot find.

    Hello Gerry,
    When you install DAQmx, there is an option to install
    support for Measurement Studio.  When you
    select this option, it will install these examples onto your hard drive.  All of the examples can be found at the
    following location: (C:\Documents and Settings\All Users\Documents\National
    Instruments\NI-DAQ\Examples\DotNET2.0\Analog Out\Generate Voltage)
    Respectfully,
    Rob F
    Test Engineer
    Condition Measurements
    National Instruments

  • Looking for audio switching answer

    Hi,
    I'm looking for a way to separate my audio out from my built in audio, maybe via USB? The only thing I can find that might enable me to do this is the Griffin iMic. All I want is to be able to switch from iTunes playback from my stereo to built in audio sounds. At the moment I have an audio out cable plugged in which disconnects the built in speakers. Is there a simper way to do this or is the iMic the way to go?
    Thanks
    iLee

    try this
    http://support.lenovo.com/en_US/downloads/detail.page?DocID=DS002475
    you should ask Lenovo for detail audio spec (and find it at audio manufactured site), or use 3rd party application, or update your windows. This is not OS related issue. Nothing much we can do here

  • I'm looking for web designer that use muse?

    Hi,
    I need someone that can take care of my website that i started with Muse, hourly pay, do you know if i can find that in the community?

    trying to add :
    - Music
    - have the option to enlarge the pictures
    - have the website work on tablet/iphone
    -add social media icon and have them linked  ex; Facebook logo linked to our Facebook etc...
    the thing i want to have my website update all the time, and i'm looking for someone to set those update when i need.
    do you have this options in your services?

Maybe you are looking for

  • I cannot send email on my iPad

    Hi, I'm using ios5 on a 32gb wifi ipad2. Before upgrading my brand new iPad from ios4.xxx I was sending emails fine. Now the iPad email app will show sending...for ages then a message will appear saying; could not send mail. Smtp server for xxxx coul

  • ERP 2005 Upgrade

    Has anyone upgraded to ERP 2005 that is using the SPL for document splitting but you have not implemented the new GL yet? We are testing for our ERP 2005 upgrade and our document splitting rules are not working correctly anymore.  OSS says that chang

  • Movie Wont Play after download

    Bought movie, all it does is "loading", then nothing. Music Videos and TV shows work great. Message was edited by: Video Help Please

  • Invoice number identification

    Dear All, how can we know that particular payment is made to vendor against paricular invoice. which field will get updated Regards.

  • Splitting the Front outp

    Hello there, i have a weird problem. I have a set of 6 channel headphones, and a 2 channel PA system in my room for all my sound from my pc. I use the 6 channel headphones when i am gaming or when i need to be quiet. I switch the speaker mode to 5. w