Note-microsoft SQL Server 2008 Tech Insider: T-SQL Language Foundation-03 Join query

Source: Internet
Author: User
Tags joins reserved

There are three basic types of joins: Cross joins, Inner joins, and outer joins. The cross join has only one step-cartesian product; There are two steps in the inner join-Cartesian product, filtering, outer join has three steps-cartesian product, filtering, adding outer row.

Inner joins

Code:

SELECT e.empid, E.firstname, E.lastname, O.orderid  from  as E   JOIN  as O      on = O.empid;

Another way to do this:

SELECT e.empid, E.firstname, E.lastname, O.orderid  from  as  as O WHERE = O.empid;

The above notation is similar to a cross join.

Outer Joins

In an outer join, to mark a table as a "reserved" table, you can use the keyword left OUTER join, the right OUTER join, and the full OUTER join between table names, where the OUTER keyword is optional. Left indicates that the row of the table to the right is reserved, and that the row of the table on the side is reserved, and full indicates that the rows of the table on both sides are preserved.

SELECT C.custid, C.companyname, O.orderid  from  as C    Left OUTER JOIN  as O      on = O.custid;

Note-microsoft SQL Server 2008 Tech Insider: T-SQL Language Foundation-03 Join query

Related Article

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.