SQL Server non-join statement differs from with join statement

Source: Internet
Author: User

1. Connect two tables query select * from TABLE1,TABLE2//2. Connecting two table queries select * FROM table1 join table2 on Table1.id=table2.id

1. The result of the first connection query is a Cartesian product: That is, the row count of table 1 multiplied by the number of rows in table 2 (each record in table one will be combined with each record in table two)
Such as:

Table One Table II

1 A

2 b

3 C

The result after the build is: 3x3 Strip records

1 A

1 b

1 c

2 A

2 b

2 C

3 A

3 b

3 C

2. The result of the second connection query is a record that conforms to table1.id=table2.d_id, and the statement after on is equivalent to a filter condition.

Table 2

ID e_name d_id D_name

1 a 1 Z

1 B 2 x

2 C

3d

The resulting query result is a record with an ID equal to d_id

ID e_name d_id D_name

1 a 1 Z

1 B 1 Z

2 C 2 x

SQL Server non-join statement differs from with join statement

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.