官术网_书友最值得收藏!

  • Learn T-SQL Querying
  • Pedro Lopes Pam Lahoud
  • 266字
  • 2021-06-24 14:38:09

FROM

The FROM clause specifies the tables or views used in the SELECT, DELETE, and UPDATE statements. It is required unless a SELECT list contains only constants, variables or arithmetic expressions, or an UPDATE clause does not contain references to other tables other than the target (for example, a join is not needed).

It can be a single table, a derived table (a table created from a nested sub-query), a Table-Valued Function (TVF), or it can be several tables and/or views joined together.

If the desired result set contains data from more than one table or view, joins can be used to link rows from one table to another. There are essentially the following three types of logical joins that are expressed when writing a query:

  • Inner joins
  • Outer joins (left, right, and full)
  • Cross joins

In specific scenarios, SQL Server may infer the intended type of logical join operation. However, it is best to always explicitly state the type of required logical join operation the reader intends to implement.

When specifying multiple tables and/or views in the FROM clause, it is helpful to create aliases for these objects, which can be used within the query, such as in the SELECT clause. This is particularly useful when different objects have columns with the same names. In this case, we must disambiguate the columns throughout the query, and an alias allows us to do this without having to specify the entire object name. So, as is the case for column aliases, a table, view, or function alias is created with the  AS keyword.
主站蜘蛛池模板: 尼木县| 运城市| 万安县| 清新县| 基隆市| 特克斯县| 九寨沟县| 客服| 桦南县| 宝清县| 永顺县| 邵东县| 类乌齐县| 大厂| 罗江县| 开化县| 栾城县| 东宁县| 吴堡县| 中方县| 射洪县| 新源县| 白玉县| 太仓市| 两当县| 临夏县| 凤山市| 霍林郭勒市| 仙桃市| 师宗县| 凤山县| 瑞金市| 筠连县| 黔西| 临猗县| 冀州市| 武川县| 金沙县| 台东市| 台北县| 兰考县|