how to query information from sub-table?

  • As some books mentioned ,Organizations and Person can be merged as a

    Party.Here is my sample:

    Party Table:

    -------------------------------

    PartyID Type

    32 Person

    40 Organization

    -------------------------------

    Person Table:

    -------------------------------

    PartyID FirstName LastName

    32 John Smith

    -------------------------------

    Organization Table

    -------------------------------

    PartyID Name

    40 aaa

    -------------------------------

    The problem is :

    Now I want to get the Party information,but it's

    stored in two tables or more(eg:Contant Mechanism)

    I don't know how to get the Party information directly from it's type

    from it's subtables if don't use case like statement.

    Any help Thanks.

  • Why do you have multiple party types? What's the point?

    But, to get all party information back, probably the best way is a UNION ALL query where you join each individual Party type to the table as appropriate.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Do you mean that I should put person and organization into one table?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply