我有2个表 kehu 和 xiaoshou
表xiaoshou的字段kid和表kehu的kid关联
用GridView显示表xiaoshou的数据
其中字段kid想显示表kehu相关联的name字段该怎么做??

解决方案 »

  1.   

    在sqlserver2000的 视图中创建一个视图  然后添加表  然后查询视图就行了
      

  2.   

    select 各字段名称 from xiaoshou and name from kuhu where kuhu.kid=xiaoshou.kid
      

  3.   

    写个存储过程就搞定了
    数据源   : select xiaoshou.?,kehu.name where xiaoshou.kid = kehu.kid
      

  4.   

    select name as kid from xiaoshou, kuhu where kuhu.kid=xiaoshou.kid
      

  5.   

    select a.kid,b.name from xiaoshou a inner join kehu b on a.kid=b.kid
      

  6.   

    感觉5楼的方法更好些,用inner join就可以
      

  7.   

    select a.kid,b.name from xiaoshou a left join kehu b on a.kid=b.kid
      

  8.   

    select kehu.name as kid,xiaoshou.各字段名 from xiaoshou, kuhu 
    where xiaoshou.kid = kehu.kid
      

  9.   

    [字段kid]  [显示]  表kehu相关联的[name字段]
    ___________________________
    lz的意思的主谓宾   应该是上面的意思吧
      

  10.   

    select xiaoshou.(想要显示的表xiaoshou中的字段),kehu.name from xiaoshou inner join kehu on xiaoshou.kid=kehu.kid