[eluser]danoph[/eluser]
you should never use like when trying to retrieve a specific person or record...
i have coded websites with buddy/friend systems before and I found the best way was creating a new table. That way, you don't have to have comma separated values in your table if bob has more than jane as a friend. what if bob is friends with mike, dan, jill, jane, jack, joe, and sally?
basically:
Code:
describe friends;
+-----------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | YES | | NULL | |
| friend_id | int(11) | YES | | NULL | |
+-----------+---------+------+-----+---------+----------------+
If bob's user ID is 1, you can get bob's friends by saying
Code:
select * from friends where user_id = '1';
I believe there are a lot more options available when using a separate table to link users together.
I think you can solve the problem of having two records by using something like:
Code:
select * from friends where (user_id = 1 and friend_id = 5) or (user_id = 5 and friend_id = 1);