请教各位:
  如何在access中利用select语句取出最大值?
  或者有没有其他的方法得到数据库中同一个类下的不同id 的最大值?

解决方案 »

  1.   

    select max(id) from table
      

  2.   


    在请教一下:
    strSql.Append("select max(id1) as a,min(id1) as b  from etw_product where categoryName=" + name + " ");  这条报错
      strSql.Append("select max(id1) as a,min(id1) as b  from etw_product"); 这条ok!
    这是为什么?语法错误 (操作符丢失) 在查询表达式 'categoryName=General Valve Series' 中。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Exception: 语法错误 (操作符丢失) 在查询表达式 'categoryName=General Valve Series' 中。源错误: 
    行 228: catch(System.Data.OleDb.OleDbException ex)
    行 229: {
    行 230: throw new Exception(ex.Message);
    行 231: }
    行 232: return ds;
     
      

  3.   

    我也没测试,你自己再测试测试吧,将strSql.Append("select max(id1) as a,min(id1) as b from etw_product where categoryName=" + name + " ");改为strSql.Append("select max(id1) as a,min(id1) as b from etw_product where categoryName='" + name + "' ");