I am a bit new to MySQL and trying my hands on learning it. However I got stuck with an query that goes as follows:
I have 2 tables: Table 1 contains details of lists created by a user. The fields are listid, listname, creatorid, createdat,membercount;
Table 2 stores data of members of each list: The fields are listid, userid;
The query I need to process is as follows: Find out all the pairs of users of the form (u1,u2) where both of the following conditions are satisfied
i. u1 has created at least one list and u2 is a member of that list.
ii. u2 has created at least one list and u1 is a member of that list.
Note: listid in the table 2 is the foreign key for listid in table 1.
How about this?
Returns every user from Table2 and the ID of the creator of the corresponding list.