要查询comid的唯一值,那么title subdircode,ssubdircode,content  这些字段不同的时候,你要决定怎么取舍,不能简单地这样列出来。

解决方案 »

  1.   

    用分组:
    select comid,min(title) subdircode,min(ssubdircode),min(content)
      from softinfo where content like '%".$key."%'
      group by comid
      order by  pub_date desc
      

  2.   

    同意~Select 在选择的时候不知道怎么选择!
      

  3.   

    要查询comid的唯一值,那么title subdircode,ssubdircode,content  这些字段不同的时候,你要决定怎么取舍,不能简单地这样列出来。你或者去最大或者取最小,否则肯定不行啊
    select comid,min(title) min(subdircode),min(ssubdircode),min(content)
      from softinfo where content like '%".$key."%'
      group by comid
      order by  pub_date desc
      

  4.   

    select comid,min(title) subdircode,min(ssubdircode),min(content)
                 --------------------- 
    这段看不懂 是不是括号打短了?
      

  5.   

    列名 'softinfo.pub_date' 在 ORDER BY 子句中无效,因为该列既不包含在聚合函数中,也不包含在 GROUP BY 子句中。
      

  6.   

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

  7.   

    select comid,min(title) subdircode,min(ssubdircode),min(cast(content as varchar(8000)))
      from softinfo where content like '%".$key."%'
      group by comid
      order by  pub_date desc