when I run query on view I get 2 record for unique id in sql server -
i have 2 table in sqlserver member , memberadress , generating view vw_member executing following query
select m.memberid, m.membername, m.endcustomer, m.expirationdate, ma.dea, ma.hin, ma.address1, ma.address2, ma.city, ma.state, ma.officecontact, ma.officecontacttitle, ma.officecontactemail dbo.member m inner join dbo.memberaddress ma on (m.memberid = ma.memberid)
but problem generating 2 record unique memberid
can tell me doing wrong ?
wild guess - there 2 rows in memberaddress
same memberid
. maybe there's concept modelled in there of address type? if so, need decide of address types should including in view, or if need an address, decision on how prioritise address types.
for second, clause might like:
from dbo.member m inner join dbo.memberaddress ma on m.memberid = ma.memberid left join dbo.memberaddress ma_anti on m.memberid = ma_anti.memberid , ma_anti.addresstype > ma.addresstype --priority decision ma_anti.memberid null
where join ma_anti
trying find "better" row memberaddress
row selected ma
- if join succeeds, don't want row in final result set, that's where
clause doing.
Comments
Post a Comment