SQL - SQL aliases, UNION and SELECT INTO

Alias (alias) - aliased table name and column name
    syntax: TABLE SELECT columnName (s) FROM tableName AS
          column SELECT columnName AS aliasName FROM tableName
    example: SELECT po.OrderID, p.LastName, p.FirstName FROM, Product_Orders AS po WHERE p.LastName = '


The UNION - SELECT statements merging two or more sets of results.
    Syntax: the SELECT columnName (S) tablename1 the FROM
          UNION
          the SELECT columnName (S) the FROM TableName2
          or
          the SELECT columnName (S) tablename1 the FROM
          UNION ALL
          the SELECT columnName (S) the FROM TableName2
    note inside the UNION SELECT statement must have the same number of columns. The columns must also have similar data types. Meanwhile, the order of columns in each SELECT statement must be the same. UNION operator to select a different value. UNION ALL operator can select duplicate values. UNION result set is always equal to the column names in the first column name UNION SELECT statement.


The INTO the SELECT - select data from one table and insert data into another table.
    Syntax: SELECT * INTO newTableName [IN externaldatabaseall columns into a new table
          SELECT columnName (s) INTO newTableName [Specifies the columns into the new table
          IN clause another database may be used to table copied

Guess you like

Origin www.cnblogs.com/it-mh/p/12035518.html