tags:

views:

31

answers:

0

I have three tables 1. MetaKey Colmans:

ID KeyName  
1  hobbies 
  1. MetaKeyValue Colmans:

    ID KeyValue: 1 skating 2 rugby 3 TV

  2. ObjectType

    ID ObjectName 1 World 2 Branch 3 Customer

  3. MapMetaKeyMetaValue

    Colmans:

    ID KeyID  ValueID ObjectID(Branch or Customer ) ObjectTypeID  isLive
    ---------------------------------------------------------------------
    1  1      1       1 (Branch ID)                  2               Y
    2  1      2       1 (Branch ID)                  2               Y
    3  1      3       1 (Branch ID)                  2               Y   
    4  1      1       1 (Customer ID)                3               Y
    5  1      2       1 (Customer ID)                3               N 
    
  4. Branch

    Colmans: ID ObjectName 1 Test

  5. Customer

    Colmans: ID Customer Name 1 TestCustomer

Now when i am at customer page i need all the Key&Values associated with Bank, at the same time Key&Values associated with the customer As below:

Now i need a query that will give following result

KeyValues       KeyID     keyName 
---------------------------------
MetaKeyValueID  KeyValue  isLive          

Some example Results

KeyValues              KeyID   keyName 
---------------------------------------
1|World|Y,2|rugby|N    1       hobbies