select table1.*,
(select path 
from table2 t2 
where t2.id=
  (select min(id) from table2 t3 where t3.code=table1.picpath)
)
from table1

解决方案 »

  1.   

    select id,name,descript,picpath,
     (select top 1 path from table2 where code = A.picpath order by id) as path
    from table1 as A
      

  2.   

    不行啊。错误为
    在这一子查询或聚合表达式中,text、ntext 和 image 数据类型无效。
      

  3.   

    tj_dns(愉快的登山者)的更简洁:)
      

  4.   

    你哪个字段是“text、ntext 和 image 数据类型”的?
      

  5.   

    select a.*,b.path
    from table1 a left join (
    select code,min(path) as path from table2 group by code
    ) as b
    on a.picpath=b.code