Eggzorcist Posted June 25, 2012 Share Posted June 25, 2012 Hi there, I have a question concerning MYSQL. I have a friend list with 3 fields, id, friend1, friend2. This highlights all the members friend relations among each other. My problem in making a friendlist is that it's difficult making a friendlist query. I'm wondering if I can select friend1 when friend2 = $username and select friend 2 when $friend1 = $username for each row. Was wondering if this is possible? Thanks Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted June 25, 2012 Author Share Posted June 25, 2012 The way I would go about doing this myself would be do a friend1 = username, friend2 = username then loop through the friend1 data with logic parameters singling them out. I was just wondering whether this is an efficient method to do this? What's another way? Quote Link to comment Share on other sites More sharing options...
requinix Posted June 25, 2012 Share Posted June 25, 2012 It'd be easier if you checked friend1 vs. friend2 in code. Get them both with SELECT * FROM table WHERE friend1 = whatever OR friend2 = whatever then $other = ($friend1 == $whatever ? $friend2 : $friend1); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.