|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Friday, February 22, 2013 12:03 AM
Points: 2,555,
Visits: 2,587
|
|
Comments posted to this topic are about the item Join Predicate
--Ramesh
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Thursday, May 09, 2013 8:55 AM
Points: 1,865,
Visits: 556
|
|
nice question. nice and sneaky.
Life: it twists and turns like a twisty turny thing
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 4:10 AM
Points: 112,
Visits: 159
|
|
I tried this query in SQL SERVER 2005,It's giving some error.It's a SQL SERVER 2008 feature?
Thanks & Regards Sagesh.K
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Tuesday, March 24, 2009 4:38 AM
Points: 780,
Visits: 162
|
|
I wonder what benefit questions like these have to the community at large. I thought the question of the day was there to inform not just to make the author feel smug!!!
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 2:04 AM
Points: 1,342,
Visits: 1,946
|
|
Sneaky.
Reminds me of the advice when reading program code (any language) ... "Don't trust the comments (or formatting?). Read the code!"
Sagesh (12/13/2007) I tried this query in SQL SERVER 2005,It's giving some error.It's a SQL SERVER 2008 feature?
Thanks & Regards Sagesh.K Worked fine for me in 2K5.
use scratch --drop table customers --drop table employees create table customers (customerid int, name varchar(10)) create table employees (employeeid int, name varchar(10)) insert customers (customerid, name) select 1,'Dave' union all select 2,'John' union all select 3,'Tom' union all select 4,'Dick' union all select 5,'Harry' insert employees (employeeid, name) select 2,'John' union all select 4,'Dick' union all select 6,'Anne' union all select 8,'Martha' GO SELECT * FROM dbo.Customers MIDDLE JOIN dbo.Employees ON CustomerID = EmployeeID
Derek
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 7:35 AM
Points: 515,
Visits: 1,016
|
|
| What benefit...? Makes you look up middle join in BOL:)
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 4:10 AM
Points: 112,
Visits: 159
|
|
Thanks for the valuable information. I checked the Query like this : "SELECT * FROM dbo.Customers AS C MIDDLE JOIN dbo.Employees E ON C.CustomerID = E.EmployeeID",so it's showing some error.If i try to join same field name in different tables,that time also i am getting some error. Like : "SELECT * FROM dbo.Customers AS C MIDDLE JOIN dbo.Employees E ON C.CustomerID = E.CustomerID "
Please provide me some usefull links to know more about MIDDLE JOIN.
Thanks & Regards Sagesh.k :)
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Tuesday, August 04, 2009 10:02 AM
Points: 814,
Visits: 915
|
|
Sagesh,
There is no MIDDLE JOIN. As MIDDLE is not a keyword or predicate and there is no alias already specified for tblCustomers, MIDDLE is taken as the alias.
Your queries do not work as you have specified an alias for the table (AS c).
Ade
A Freudian Slip is when you say one thing and mean your mother. For detail-enriched answers, ask detail-enriched questions...
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 3:17 PM
Points: 5,270,
Visits: 11,212
|
|
26% got this correct. How many of them got this right by luck, not having realised no such thing as middle join?
I am very upset to have missed out on a chance to get a point for getting something wrong
---------------------------------------------------------------------
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 2:04 AM
Points: 1,342,
Visits: 1,946
|
|
Sagesh (12/13/2007) Thanks for the valuable information. I checked the Query like this : "SELECT * FROM dbo.Customers AS C MIDDLE JOIN dbo.Employees E ON C.CustomerID = E.EmployeeID",so it's showing some error.If i try to join same field name in different tables,that time also i am getting some error. Like : "SELECT * FROM dbo.Customers AS C MIDDLE JOIN dbo.Employees E ON C.CustomerID = E.CustomerID "
Please provide me some usefull links to know more about MIDDLE JOIN.
Thanks & Regards Sagesh.k :)
That's because you've rewritten the query and broken it!
The point is that the AS keyword is optional, so SQL server readsSELECT * FROM dbo.Customers MIDDLE JOIN dbo.Employees ON CustomerID=EmployeeID
as SELECT * FROM dbo.Customers AS MIDDLE JOIN dbo.Employees ON CustomerID=EmployeeID
When you rewrote it, you inserted "AS C" after the name of table Customers, so now the word "MIDDLE", which isn't a keyword, is unexpected and you get an error!
Because the words "MIDDLE JOIN" have been formatted in upper case and put at the start of a new line, people get fooled into thinking it's a new type of join, when it's just aliasing the Customers table with the name 'MIDDLE'. There is no such thing as a middle join!
Derek
|
|
|
|