|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, December 20, 2012 1:03 PM
Points: 265,
Visits: 589
|
|
Goes to prove that you get hanged by the same clever rope you wove.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Yesterday @ 4:08 PM
Points: 220,
Visits: 352
|
|
| Argh! The question changed from the email and I didn't read the web page's version of the question!
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 12:52 PM
Points: 3,231,
Visits: 64,365
|
|
Steve Jones - Editor (5/27/2009)
The corrected question, which is on the web site, is CREATE TABLE E (eid int, mid int, en char(10) ) INSERT E SELECT 1,2,'Vyas' INSERT E SELECT 2,3,'Mohan' INSERT E SELECT 3,NULL,'Shobha' INSERT E SELECT 4,2,'Shridhar' INSERT E SELECT 5,2,'Sourabh' SELECT t1.en [Em], t2.en [Ma] FROM E t1, E t2 WHERE t1.mid = t2.eid order by t1.en There is no way you can get "Vyas Mohan" first. Running the SQL from the newsletter kind of defeats the purpose in answering. The idea is for you to use your knowledge to figure it out.
Sure you can... read it from top down without the ORDER BY.
eid 1 gives you Vyas which joins to eid 2 and gets Mohan Vyas Mohan followed by Mohan eid 2 joining to eid 3 and getting Mohan Shobha
if you read the email, figured out what you were doing, and then clicked the link, and answered the question (because you didn't see the order by.. on my machine it was hidden by a scrollbar at first), you'd easily get Vyas Mohan first.
--Mark Tassin MCITP - SQL Server DBA Proud member of the Anti-RBAR alliance. For help with Performance click this link For tips on how to post your problems
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, June 16, 2010 10:55 AM
Points: 33,
Visits: 113
|
|
| You're right, my response was somewhat whiny given that the original post was most likely a keyboard error, not a logic error. I'll save my criticisms for when I've accumulated enough points to be classified something beyond Grasshopper.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, June 07, 2011 7:20 AM
Points: 432,
Visits: 83
|
|
| I typically read the email, solve the problem in my head, click the link and select the answer I got. Now you're saying I have to ignore the email because what is in there doesn't reflect the actual question? Sounds like a weasel answer to me. Just admit the question was not properly edited in both the content or the alternative presentations and move on.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 11:22 AM
Points: 1,268,
Visits: 1,477
|
|
Barry McConnell (5/27/2009) I typically read the email, solve the problem in my head, click the link and select the answer I got.
That's my MO, too. I don't expect there to be a difference between the newsletter and the website.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924,
Visits: 1,554
|
|
WOW.........never seen so many complaints for a single question on QOD before. Good job Reddy. You made all forum posters stand united.
SQL DBA.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Sunday, May 12, 2013 6:55 PM
Points: 119,
Visits: 111
|
|
Question
Why is the inner join the recommended option ? I know Microsoft recommends this way but no where can I find a reason ? According to the execution plan both are the same and both cost 50%
SELECT t1.en [Em], t2.en [Ma] FROM E t1, E t2 WHERE t1.mid = t2.eid order by t1.en
SELECT t1.en [Em], t2.en [Ma] FROM E t1 inner join E t2 on t1.mid = t2.eid order by t1.en
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, June 07, 2011 7:20 AM
Points: 432,
Visits: 83
|
|
SanjayAttray (5/27/2009) WOW.........never seen so many complaints for a single question on QOD before. Good job Reddy. You made all forum posters stand united.You must not have seen the MDX Except question then!
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, June 07, 2011 7:20 AM
Points: 432,
Visits: 83
|
|
cj_logan (5/27/2009)
Question
Why is the inner join the recommended option ? I know Microsoft recommends this way but no where can I find a reason ? According to the execution plan both are the same and both cost 50%
SELECT t1.en [Em], t2.en [Ma] FROM E t1, E t2 WHERE t1.mid = t2.eid order by t1.en
SELECT t1.en [Em], t2.en [Ma] FROM E t1 inner join E t2 on t1.mid = t2.eid order by t1.en
Because that is part of the ANSI standard for SQL. The older syntax should be phased out. The argument goes that the new syntax is cleaner by separating the JOIN logic from the filter (WHERE) logic.
|
|
|
|