mysql query for getting all messages that belong to user's contacts
- by aharon
So I have a database that is setup sort of like this (simplified, and in terms of the tables, all are InnoDBs):
Users: contains based user authentication information (uid, username, encrypted password, et cetera)
Contacts: contains two rows per relationship that exists between users as
(uid1, uid2), (uid2, uid1) to allow for a good 1:1 relationship
(must be mutual) between users
Messages: has messages that consist of a blob, owner-id, message-id (auto_increment)
So my question is, what's the best MySQL query to get all messages that belong to all the contacts of a specific user? Is there an efficient way to do this?