在Sql语句中看到
表名+变量名 的部分,
比如数据库中有表Table1
Table1 tableSample
这样的操作有什么用? tableSample是一个包含了Table所有内容的表吗?

解决方案 »

  1.   

    你的sql上下文是什么?
    你只这样写,看不出来啊。
      

  2.   

    多表链接的时候,表字段有重复,建议这样子操作
    如:select a.a,b.a from a,b where a.a=b.a
      

  3.   

    比如下面例子中,红色部分的原理介绍一下。
    select tableSample.status_time as time,
    tableSample.time - 1 / 24 / 60 * 5 * t.delay as Upstream_Time,
                                            t.delay,
                                            t.ID,
                                            t.weight
                                       from Table2 t,
                                           TABLE1 tableSample                                  where t.index = : Index
                                        and t.cycle = : Cycle
      

  4.   

    select tableSample.status_time as time,
    tableSample.time - 1 / 24 / 60 * 5 * t.delay as Upstream_Time,
      t.delay,
      t.ID,
      t.weight
      from Table2 t,
      TABLE1 tableSample where t.index = : Index   --表的别名
      and t.cycle = : Cycle
      

  5.   

    TABLE1是一个表的名字,而tableSample为表的别名。
      

  6.   

    select tableSample.status_time as time,
    tableSample.time - 1 / 24 / 60 * 5 * t.delay as Upstream_Time,
      t.delay,
      t.ID,
      t.weight
      from Table2 t,
      TABLE1 tableSample where t.index = : Index
      and t.cycle = : Cycle
    tableSample 是表的别名,多表联合查询时,相同列名需要在前面加表名(或别名)以示区别.
    表名称比较长时,用短别名更方便.