You would make it easier on yourself if you could accept reciprocal likes since A might like B but does that automatically mean that B likes A? Otherwise you are faced with some difficulty in allowing an A B combination in a table but not a B A. If allowed, you could have something like tblNames with all the related data
MemberID |
Fname |
Lname |
UsrName |
1 |
Dave |
Brown |
Funky |
2 |
Frank |
Smith |
Spanky |
3 |
Jill |
Jones |
Aura |
4 |
Jane |
Doe |
Misty |
5 |
etc |
etc |
etc |
6 |
etc |
etc |
etc |
The ID field values could be stored in tblLikes. Substituting your letter values with these numbers:
LikeID |
Like1 |
Like2 |
1 |
1 |
2 |
2 |
2 |
3 |
3 |
4 |
6 |
4 |
6 |
1 |
Combine fields Like1 and Like2 into a unique index (or composite primary key) so that you don't repeat, say, a 2-3 combination. I would prevent repeating values such as a 2-2 combination in the form code that is used to populate tblLikes. Since you want to put the same value from different records into one field, I see a need for a Union query. Your query would look something like
Code:
SELECT tblLikes.Like2 AS Liking
FROM tblMembers INNER JOIN tblLikes ON tblMembers.MemberID = tblLikes.Like1
WHERE (((tblLikes.Like1)=1))
UNION
SELECT tblLikes.Like1 AS Liking
FROM tblMembers INNER JOIN tblLikes ON tblMembers.MemberID = tblLikes.Like1
WHERE (((tblLikes.Like2)=1));
If you want to see other fields such as names, add them to the individual query parts.
Last edited by Micron; 10-14-2016 at 10:27 PM.
Reason: edit sql
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.