SQL Server link Query

Source: Internet
Author: User
Tags one table

One, the connection
query with a connection when there is more than one table in the result set

1. Internal connection:
multiple tables connected according to public columns, eligible for display, non-eligible for display
2. External connection:
Multiple tables display all the information in a table based on a common column connection, the information in the other table that meets the criteria, and non-conforming null-padded
Internal Connection query syntax:
SELECT * FROM table 1
[Inner]join table 2
On condition (public column)

outer JOIN query syntax:
SELECT * FROM table 1
[Left][right]join table 2
On condition (public column)
 
second, SQL programming
1. Local variable @ name--the user's own definition
declaring variables:
DECLARE @ variable name type
assign a value to a variable:
set:a. Assigning values to multiple variables at once is not supported, B. An expression cannot have more than one value.
c. The variable is null when an expression has no return value
Select a. Supports assigning values to multiple variables at once, B. An expression can have more than one value, but only the last value. C. An expression has no return value when the variable remains the original value
the value of the output variable:
Print String
Select variable 1, variable 2
   
2. Global variable @@ 名称--The system defines the assigned value, the user can only access
@ @indenity current Maximum ID
@ @error The most recent SQL statement error number

SQL Server link 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.