SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 Join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Shaimaa T
Starting Member

Egypt
1 Posts

Posted - 08/22/2014 :  09:32:53  Show Profile  Reply with Quote
Hi all,

Can someone help explain to me how when I have 12 rows in table A and 10 in B and I do an inner join , I would get more rows than in both A and B ?

Same with left and right joins...

This is just a simplified example. Let me share one of my issues with you

I have 2 views ; which was originally SQL on 2 base tables Culture and Trials.

And then when attempting to add another table Culture Steps, one of the team members separated the SQL into 2 views

Since this produces an error when updating(modification cannot be done as it affects multiple base tables), I would like to get back to changing the SQL such that I no longer use the views but achieve the same results.

One of the views has

SELECT       some columns
FROM            dbo.Culture RIGHT JOIN
                         dbo.Trial ON dbo.Culture.cultureID = dbo.Trial.CultureID LEFT OUTER JOIN
                         dbo.TrialCultureSteps_view_part1 ON dbo.Culture.cultureID = dbo.TrialCultureSteps_view_part1.cultureID


The other TrialCultureSteps_view_part1 view

SELECT DISTINCT dbo.Culture.cultureID,
                             (SELECT        TOP (1) WeekNr
                               FROM            dbo.CultureStep
                               WHERE        (CultureID = dbo.Culture.cultureID)
                               ORDER BY CultureStepID) AS normalstartweek
FROM            dbo.Culture INNER JOIN
                         dbo.CultureStep AS CultureStep_1 ON dbo.Culture.cultureID = CultureStep_1.CultureID


So how can I combine the joins the achieve the same results using SQL only on tables without the need for views?

gbritton
Flowing Fount of Yak Knowledge

1445 Posts

Posted - 08/22/2014 :  10:45:52  Show Profile  Reply with Quote
duplicate of

http://www.sqlservercentral.com/Forums/Topic1606290-2799-1.aspx?Update=1
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000