select distinct a.*,b.* from a,b where a.id=b.id and a.id='1'

解决方案 »

  1.   

    这是因为你的b表中id=1的记录有很多条的原因,
      

  2.   

    select c.*,b.*
    from (select '1',xm,sum(gh) as gh from a where a.id='1' group by xm ) c , b where
    c.id=b.id  
      

  3.   

    select a.*,b.xx from a,b where a.id=b.id and a.id='1'
      

  4.   

    select a.id,a.xm,a.gh,b.xx from a,b where a.id=b.id and a.id='1'
      

  5.   

    select a.id,a.xm,a.gh from a join select b.xx from b on a.id = b.id
    where a.id = '1'
      

  6.   

    select * from a where a.id='1' union
    select xx from b where b.id='1'
      

  7.   

    select * from we_project where recid='2003031313213751769656'(一条)
    select * from is_files where doc_id='2003031313213751769656'(两条)
    select distinct a.*,b.file_name from we_project a,is_files b where a.recid=b.doc_id and a.recid='2003031313213751769656'(两条!我想的到一条)
    select * from we_project where recid='2003031313213751769656' union select * from is_files where doc_id='2003031313213751769656'(报错了!!包含 UNION 运算符的 SQL 语句中的所有查询都必须在目标列表中具有相同数目的表达式。)
      

  8.   

    当select * from is_files where doc_id='2003031313213751769656'没有记录时也要的到一条is_files中的file_name显示为null,有人会吗!救命啊!
      

  9.   

    try:
    select identity(1,1) as temp_id,a.*,b.xx into #temp from a,b where a.id=b.id 
    select (select max(b.temp_id) from #temp b where a.id=b.id) as temp_id,a.id,a.字段1,a.字段2,..... from #temp