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