代码之家  ›  专栏  ›  技术社区  ›  Steve Cooper

搜索SQL短语的精确术语

sql
  •  4
  • Steve Cooper  · 技术社区  · 14 年前

    select child.ID, parent.ID
    from hierarchy child 
    inner join hierarchy parent 
    on child.parentId = parent.ID
    

    然后有一个实际的表(“hierarchy”),你给了它两个名称(“parent”和“child”),我的问题是你如何用一个名称引用表的逻辑实体。

    你会在这里的空白处写上什么名字?

    “此查询使用一个表(层次结构),但使用两个 _

    4 回复  |  直到 14 年前
        1
  •  2
  •   AakashM    14 年前

    在SQL Server文档中,术语是 table_source :

    指定要在Transact-SQL语句中使用的表、视图或派生表源(带或不带别名)

    <table_source> ::= 
    {
            table_or_view_name [ [ AS ] table_alias ] [ <tablesample_clause> ] 
            [ WITH ( < table_hint > [ [ , ]...n ] ) ] 
        | rowset_function [ [ AS ] table_alias ] 
            [ ( bulk_column_alias [ ,...n ] ) ] 
            | user_defined_function [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ]
        | OPENXML <openxml_clause> 
        | derived_table [ AS ] table_alias [ ( column_alias [ ,...n ] ) ] 
        | <joined_table> 
        | <pivoted_table> 
        | <unpivoted_table>
          | @variable [ [ AS ] table_alias ]
            | @variable.function_call ( expression [ ,...n ] ) [ [ AS ] table_alias ] [ (column_alias [ ,...n ] ) ]
    
        2
  •  5
  •   Larry Lustig    14 年前

    我相信这叫做自我加入。A和B(或者“child”和“parent”,我认为您的问题中有一个拼写错误)称为别名或表别名。

        3
  •  4
  •   Fosco    14 年前

    self join . 然而 a 是语法错误。桌子是 hierarchy ,别名为 child

    instance .

        4
  •  1
  •   onedaywhen    14 年前
    'child', 'parent'
    

    'hierarchy'
    

    SQL-92标准规范中使用的术语是“表”。

    此查询使用一个表(层次结构) 但是有两个相关的名字(child和