Solved

Reversing an Inner Join

Posted on 2004-08-26
2
388 Views
Last Modified: 2006-11-17
I have a query that looks like this:

SELECT fname, member.id, filename, friendID,memberFriends.memID, statusID
FROM MEMBER
INNER JOIN memberFiles on member.id = memberfiles.memID
INNER JOIN memberFriends on member.id = memberFriends.friendID
WHERE memberFriends.memID = 19 OR memberFriends.FriendID = 19
AND ID != 19

Basically, it establishes a relationship between two members. It works, returning the "friends" of the member who
s ID is specified. The problem is that when their friend's profile is accessed that member does not show up in the query.

In other words, I need to be able to find all members who friendID matches a memberID, which is the reverse of what this query produces.

Does that make sense?

-- Jenni
0
Comment
Question by:JenniQ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
NickUpson earned 125 total points
ID: 11913031
Please post the table structure for all the tables?
Is the memberFiles table needed to achieve your description for the current query?

I think this does what you want but I may have misunderstood the situation

select m.id, m.fname from memberfrends mf
inner join member m on mf.memid = m.id
where mf.friendid = 27
0
 
LVL 3

Author Comment

by:JenniQ
ID: 11917737
That query does find what I was asking, but I was looking for a query that produced that result along with the results of my previous query. I think I need to rethink the way this works. Thanks for your help!

-- Jenni
0

Featured Post

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question