mysql - SQL get friends from friends table by username -


Okay, I'm stuck with the table design which I can not change now and I'm going to get the username Based on the relationship table between all your friends in relation to friends

What I have now:

  select different (user name) from members. Join the internal member at f.id_memb_friend1 = m.id. I F.id_memb_friend1 = 173 or f.id_memb_friend2 = 173)   

The members table has columns: id, use In the name of the member name mailer, the column ID, id, id_memb_friend1, id_memb_friend2

query has returned the user's name to the user name ID 173 which is the owner and for example, his nickname is magnificent. Based on the username that I provide (Great = ID 173), all the friends have to meet together with the user name.

Update:

I want to receive it:

Input: Username = Great actions: Get names of great friends (with their ID) Output:

members.id = 5 user name = John

subscribers .id = 15 user name = Lara

members.id = 66 username = Alex

and so on ...

(new requirement expressed in comments Up to adjust (Updated to accommodate the new requirement expressed in the updated question.)

Your question (s) was incompatible with whether you have a username or user ID Want to search on the basis. Although your query uses ID, I use the username as per the specification. I also believe that you want the friend 'username (only) In addition, this seems like your initial query that you want to see the relationship in both directions (display on match 1, show all friend 2, and match on friend 2, show all 1 friend).

Here's one of the ways that:

  select mm.id, mm.us member member from m.m. Join F_id_memb_friend1 = Member at mm.id. MIID = Internal member at f.id_memb_friend2 where I select the user name = 'brilliant' union mm.id, mm.us member member from mm. Interval can include f.id_memb_friend2 = mm.id at m.id = f.id_memb_friend1 mid = m.username = 'splendid'    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -