Click here to Skip to main content
Click here to Skip to main content

Tagged as

Best Practices to tune up T-SQL and SP

, 2 Mar 2012
Rate this:
Please Sign up or sign in to vote.
I can't imagine that a correlated subquery is your best answer here:SELECT name FROM teacher WHERE EXISTS (SELECT 1 FROM student WHERE teacher.teacher_id = student.teacher_id)Instead, how about an INNER JOIN?SELECT DISTINCT teacher.nameFROM teacher INNER JOIN student ...
I can't imagine that a correlated subquery is your best answer here:
 
SELECT name FROM teacher WHERE EXISTS (SELECT 1 FROM student WHERE teacher.teacher_id = student.teacher_id)
 
Instead, how about an INNER JOIN?
 
SELECT DISTINCT teacher.name
FROM teacher
    INNER JOIN student
        ON teacher.teacher_id = student.teacher_id

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Drew Rhoades
Technical Lead PDI
United States United States
No Biography provided

Comments and Discussions

 
Generalhttp://sqlserverpedia.com/blog/sql-server-bloggers/sql-serve... PinmemberJeremy Hutchinson6-Dec-10 7:55 
QuestionTry this Pinmembere-Lopes2-Mar-12 12:42 
GeneralRe: Try this PinmemberDrew Rhoades5-Mar-12 3:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 2 Mar 2012
Article Copyright 2012 by Drew Rhoades
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid