Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 Join

Author  Topic 

Shaimaa T
Starting Member

1 Post

Posted - 2014-08-22 : 09:32:53
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
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-22 : 10:45:52
duplicate of

http://www.sqlservercentral.com/Forums/Topic1606290-2799-1.aspx?Update=1
Go to Top of Page
   

- Advertisement -