MSSQLServer database-left join followed by where to become an inline workaround

Source: Internet
Author: User
Tags mssqlserver

Follow the left join followed by where it becomes inline. Baidu after seeing this solution.

The records are as follows:

Select SRE. * , Co.description    from  Left outer Join  on Sre.locationincdr=co.optionvalue  where co.optionname= ' LOCATIONINCDR ';

Select SRE. * , Co.description    from  Left outer Join Custom_options Co    on (Sre.locationincdr= and Co.optionname='locationincdr  ');

The first SQL is a left outer join and then the where filter. Careful analysis of this SQL will find that the final result is not expected, the Custom_options table in the non-qualifying record is null, due to the filter in where, resulting in the query out of the portion of the null record is not queried. The left outer connection is no different from the inner connection.

The second SQL statement will meet the requirements. When you make a connection, you filter out some of the records on the right, so that even the left table record that doesn't match the right table can be queried.

MSSQLServer database-left join followed by where to become an inline workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.