Hey everyone,
I have a messaging system setup using two mysql tables, one for the message (inc text, subject, sender info etc) and another for the recipient info (containing messageid and recipientid) which allows for multiple recipients. I am trying to write a query to enable the deletion of a user (which in turn will delete all their messages). Obviously if i do:
$queryg = "DELETE TMessages.*, TMessageRecipients.* FROM TMessages, TMessageRecipients WHERE TMessages.Fid=TMessageRecipients.FMessageID AND TMessageRecipients.FUserID='$uid'";
Where uid is their userid then it will delete all related records in both tables (so all messages to and from them). The problem is this will also delete messages that were sent to them AND other people. Is there anyway to only delete records if the associated record in TMessageRecipients is unique (ie there isn't another record in there with the same MessageID)?
If that's not entirely clear then do ask me to clarify anything! Thanks so much for your help, i think there must be a way to do it, but i'm not sure how!
Dave