I have a relationship table in my database that has four values AKA...
id, int, primary, auto-incriment
mem1, int
mem2, int
type, enum('a','b')
I also have another table that has the members id, username, firstname, and lastname
I want to click a button and get the relationships between the two people without duplicates. Here is the query I have so far...
SELECT
myMembers.id AS id,
myMembers.username AS username,
myMembers.firstname AS firstname,
myMembers.lastname AS lastname
FROM myMembers
INNER JOIN memberRelations
ON memberRelations.mem2=myMembers.id
WHERE memberRelations.mem1='$id' OR memberRelations.mem2='$id' ORDER BY myMembers.username
ASC
The problem here is that on some users it gives me the correct values, but on others it gives me the profile user and not the other member relationship. I suspect this has to do with the ON portion of the query, but truthfully I am lost! Is there a better way to accomplish my goal? Or can I just correct something in my query? Any help would be greatly appreciated. Thanks!