Wednesday, April 3, 2013

Display/Retrieve store relationships involving a particular store

DB Query

select s1.identifier as store, s2.identifier as relatedstore, sr.name
from storeent s1, storeent s2, storerel s1_s2, streltyp sr
where s1.storeent_id=s1_s2.store_id
    and s2.storeent_id=s1_s2.relatedstore_id
    and (s1_s2.store_id=STORE_ID or s1_s2.relatedstore_id=STORE_ID)
    and store_id<>relatedstore_id
    and sr.streltyp_id=s1_s2.streltyp_id
;

No comments:

Post a Comment