Page 1 of 1

Not allowing duplicate records

Posted: Wed Aug 16, 2006 7:28 am
by Wardy7
I have a database that has the following userid, frienduserid, friendusername in it.

What happens is that a user (userid) can add anotehr user as their friend.
So this means any user can add any other user to their friends list.
When a user clicks on the "add friend" link on my site the details are updated with the "new friend partnership". What I am havign problems with is that a user can add the samne friend as many times as they want, so what I need is that if a user alreday has a friendship then if they try to add another then it doesn't get added.

Can anyone help please?

Cheers
Wardy

Posted: Wed Aug 16, 2006 7:46 am
by feyd
friendusername technically isn't needed for this table.

As for the proper query to see if an entry already exists, it would be a JOIN between the user table and frienduserid. You've already got the right userid and will need that too, but no join is required for that field.