Advertisement

12.10.2007 at 03:42AM PST, ID: 23012665
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

inner join with multiple tables

Asked by jimbona27 in MS SQL Server, SQL Server 2005

Tags: , , ,

Hi EE,
I have the following query in sql although Im not confident with multiple inner joins.
Can you please help with why this fails.

As you can see I have five tables in the query, outlined below:

article
article_ad
comments
rating
members

the article table is the main data provider.

for every article there is a member id.  the link between member and article is always there so there doesnt need to be a left or right join on this relationship.

The following comments can be summarised to say that the article and member table can have a straight join.  All other tables need to have an inner join to the article table..  When I say inner join I mean that if a record exists in the article id the query must return a table, i.e. all other table data will return null.

an article may or may not have an entry in the article_ad table.  therefore i need a left join between these article and article_ad so that when the article entry does not have an entry in the article_ad table the article_ad columns within the resultant table return NULL.

identical to the previous point, the article may or may not have a comment.  for this reason the relationship between the article and comments table needs a left join so that if there are no comments for the article the comment columns return NULL.

my main cause for posting is im not too sure whether this line from the code snippet

LEFT JOIN      rating as r
ON            r.articleid = article.id,
            members as m

means the members table is included within the left join or not.




Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
SELECT		top 1 *
FROM		(article as a
LEFT JOIN	article_ad as article_ad
ON		article_ad.articleid = article.id)
LEFT JOIN	comments as c
ON		c.articleid = article.id
LEFT JOIN	rating as r
ON		r.articleid = article.id,
		members as m
WHERE		a.memberid = m.id
AND		a.id = c.articleid
AND		a.id = 1
[+][-]12.10.2007 at 03:48AM PST, ID: 20440741

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.10.2007 at 03:49AM PST, ID: 20440745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.10.2007 at 03:51AM PST, ID: 20440751

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, SQL Server 2005
Tags: multiple, join, inner, tables
Sign Up Now!
Solution Provided By: jindalankush
Participating Experts: 3
Solution Grade: A
 
 
[+][-]12.10.2007 at 04:00AM PST, ID: 20440784

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.10.2007 at 04:04AM PST, ID: 20440801

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]12.10.2007 at 06:52AM PST, ID: 20441867

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628