比如数据库里本来就有 
1              东 
2              西 
3              南 
…… 
这张表 
gridview可能是这样: 
编码 








…… 我想在点击按钮时 把这一列变成对应的 
东 
西 
西 
南 
北 
……
请问如何写这个sql语句?

解决方案 »

  1.   

    比如数据库里本来就有 
    编码             mame
    1              东 
    2              西 
    3              南 
    …… 
    这张表ta select b.name
    from gridview a
    left join ta b
    on a.编码 = b.编码
      

  2.   

    tb1
    col1           col2
    1              东 
    2              西 
    3              南 
    …… gridview
    编码 








    …… select tb1.col2 from tb1 , tb2 where tb1.col1 = tb2.编码
      

  3.   

    那这不是SQL的内容了,设置控件的显示属性吧.
      

  4.   

    select b.name 
    from tb a inner  join ta b on a.编码 = b.编码
      

  5.   

    sql语句如上写完之后
    在控件的点击事件中重新绑定数据源
    如果是用了ajax的话,记得调用updatepanel的update方法
      

  6.   


    select table1.col2 from table1 , table2 where table1.col1 = table2.编码
      

  7.   


    declare @tableA table (id int,fx varchar(4))
    insert into @tableA
    select 1,'东' union all
    select 2,'西' union all
    select 3,'南' union all
    select 4,'北' union all
    select 5,'东南' union all
    select 6,'西北'select * from @tableA
    declare @tableB table (编码 int)
    insert into @tableB
    select 1 union all
    select 2 union all
    select 2 union all
    select 3 union all
    select 1 union all
    select 4 union all
    select 6 union all
    select 4select * from @tableBselect b.编码 , a.fx from @tableA a right join @tableB b on b.编码=a.id
    /*
    编码          fx
    ----------- ----
    1           东
    2           西
    2           西
    3           南
    1           东
    4           北
    6           西北
    4           北
    */
      

  8.   

    把数据分别绑在两列上,然后用按钮控制gridview的列隐藏还是显示就可以了。