Left join would not work with a "where" clause

  • Well I am dealing with very small number of records, something like 30+ so I am not much concerned about performance. Especially having the fact that the job runs once a week.

    As for using '%', '_' or equality operand, since my databases names look like HotDog{two letter country code}XYZ, I found using '_' works the best for me. If the databases were named something like this HotDog{two letter country code}, I could probably use left(db_name, 6) and equality operand.

    I am open to other ideas though. 🙂

  • I'm not one to argue with results! Theory is often best practiced in the classroom:-)

    --SJT--

  • When the query is executed - the JOIN clause gets evaluated first and the WHERE Clause operates subsequently on the rows returned by the JOIN clause. It seems therefore that in the earlier version of the query - the JOIN clause itself was not sufficient in that it was not returning the right result set rendering the WHERE clause ineffective. It sounds that promoting the condition to the JOIN clause helped in retrieving the correct rows upfront.

    Again the filtering on the NULL actually makes the other conditions useless as pointed out by another poster. Be that as it may, would the OP kindly confirm this is what was happening so I can verify my understanding?

    Saurabh Dwivedy
    ___________________________________________________________

    My Blog: http://tinyurl.com/dwivedys

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537

    Be Happy!

Viewing 3 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply