Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Advanced SQL/Oracle Question

Options
  • 26-11-2008 3:26pm
    #1
    Closed Accounts Posts: 5,029 ✭✭✭


    Hi Lads,

    Quick question here. I'm not lazy enough to be looking for a neatly packaged solution or anything :D, just a few pointers in the right direction.

    My problem is I have two tables, where the second one has a description to be associated with a name on the first table.

    The 'name' exists in a full form on the first table e.g. John Smith but the 'name' on the second may be the full name or an initial string ending in a % wildcard.

    There is also the issue of the entries on the second table being public or private.

    I want to associate (join) the description on the second table with the entries on the first table with the following type of hierarchy:

    # Public wildcard e.g. John%
    which can be overridden by
    # Public fully qualified e.g. John Smith
    which can be overridden by
    # Private wildcard e.g. John%
    which can be overridden by
    # Private fully qualified e.g. John Smith

    Is there any way to do this with some advanced well constructed SQL statement, or am I looking at multiple SQL statements and then business logic in my server side code (Java)?

    Any help appreciated. :)
    Tagged:


Comments

  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    Looks trivial enough, but I don't understand what you mean by "overridden".


  • Closed Accounts Posts: 5,029 ✭✭✭um7y1h83ge06nx


    Probably a bad choice of words.

    What I mean is if the second table is something like this:

    Private John Smith "My full private description for John Smith"
    Public John% "Public description for all Johns"
    Public John Smith "Public description for John Smith"
    Private John S% "My Private description for all John S's"

    I want the SQL statement to join the description "My full private description for John Smith" to John Smith's entry on the first table, as that would be the most accurate description, with the Public John% being the least accurate.

    I don't know however what the entries are on the second table, just that I want the more 'accurate' descriptions used over the less 'sccurate' one.

    Can SQL do this sort of hierarchy rule?

    Thanks.


  • Registered Users Posts: 1,453 ✭✭✭showry


    What's the structure of the tables?

    Can you provide some sample data from both tables?


  • Registered Users Posts: 2,781 ✭✭✭amen


    are all the entries in the one column on the second table?
    sample data would be helpful?


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    Probably a bad choice of words.

    What I mean is if the second table is something like this:

    Private John Smith "My full private description for John Smith"
    Public John% "Public description for all Johns"
    Public John Smith "Public description for John Smith"
    Private John S% "My Private description for all John S's"

    I want the SQL statement to join the description "My full private description for John Smith" to John Smith's entry on the first table, as that would be the most accurate description, with the Public John% being the least accurate.

    I don't know however what the entries are on the second table, just that I want the more 'accurate' descriptions used over the less 'sccurate' one.

    Can SQL do this sort of hierarchy rule?

    Still not fully getting what you are after, but sample data and table structure would help immensely.

    I am beginning to think you need four CASE statements:

    CASE Private John Smith -> 'My Full private description....'
    CASE Public John% -> 'Public description for all johns....'

    and so on.


  • Advertisement
Advertisement