I have a contact table, and the contacts have contctinterests that is joined to the master lookup table of interest.
I want to retrieve a list of all the interests and join in the contacts interests whether or not they have a corresponding contactinterest.
I wrote:
select i.interestid, i.interest, i.sortorder, ci.interestid from interest i
left outer join contactinterest ci on i.interestid = ci.interestid
where i.active = 1 order by i.interestid, i.interest
However, this returns the interests (master table) more than once.
What I am seeking is a lists of all unique interests, and then a field that determines if this person has that particular interests.
Example
Interest
A 1
B 1
C NULL
D 1
E NULL
This means the interests are A through E and this person had interest A, B, and D in the contractinterest table.
I hope this makes sense. Thanks in advance for your help.
Jim
I want to retrieve a list of all the interests and join in the contacts interests whether or not they have a corresponding contactinterest.
I wrote:
select i.interestid, i.interest, i.sortorder, ci.interestid from interest i
left outer join contactinterest ci on i.interestid = ci.interestid
where i.active = 1 order by i.interestid, i.interest
However, this returns the interests (master table) more than once.
What I am seeking is a lists of all unique interests, and then a field that determines if this person has that particular interests.
Example
Interest
A 1
B 1
C NULL
D 1
E NULL
This means the interests are A through E and this person had interest A, B, and D in the contractinterest table.
I hope this makes sense. Thanks in advance for your help.
Jim