declare @categoryid int
select
  c.categoryid,
  c.name,
  n.title,
  n.createtime
from
  category c,
  news n
where
  c.categoryid=n.foreignid
and
  c.categoryid=@categoryidfrom里定义数据表的缩写 实在有些不方便 内容一些多就容易眼花
还有什么好的方法可以定义表缩写的?

解决方案 »

  1.   

    定义别名...
    select * from 表 as a 
      

  2.   

    别名前面加个AS,
    格式采用
    from 
      category  as c, 
      news as  n ,
    中列式 清晰
      

  3.   

    declare @categoryid int 
    select 
      c.categoryid, 
      c.name, 
      n.title, 
      n.createtime 
    from 
      category c,   news n 
    where 
      c.categoryid=n.foreignid and   c.categoryid=@categoryid 
      

  4.   

    select c.categoryid,c.name, from category as c这样和原来的没区别啊  等于在中期定义全局了????