mysql query for getting all messages that belong to user's contacts
Posted
by aharon
on Stack Overflow
See other posts from Stack Overflow
or by aharon
Published on 2010-06-13T03:37:32Z
Indexed on
2010/06/13
3:42 UTC
Read the original article
Hit count: 337
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?
© Stack Overflow or respective owner