Solved

Reversing an Inner Join

Posted on 2004-08-26
2
372 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
syadmin MSSQL 2 66
Question about consuming GB from Comcast 5 54
SQL SELECT query help 7 37
Teradata converting character to integer 2 16
In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
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…

770 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