Hello,
I'm having problems with design correct SQL query. I'm tired like a hell today, been working over 12 horus (deadline soon) and cannot find issue...
Tables:
buddies | userid | buddyid
users | id | username
Now, what I'd like to do: Query table buddies for all user friends (when ID = userid OR ID = buddyid). Having no problems with that.
Problem comes when I try to join users table to get username, username is NULL, can't find out why.
Would you like to help me?
Here's working query (but returning empty username)
SELECT username
FROM (
`users_buddies`
)
LEFT JOIN `users` ON ( 'users.id' = 'buddyid'
OR 'users.id' = 'userid' )
WHERE `userid` =1
OR `buddyid` =1
Thanks in advance for any help. I'm more than sure it's tiny bug (caused by me) but really cannot find it. Spent over one hour on this, then decided to ask.
Regards, Tom