看你的sql是不是从相同日期里面选择一个最小的id出来?
稍微优化一下
select min(a.id) from blogs where a.dayinfo='2008-04-09'你要用变量代替的话那就用拼字符串或者写参数咯
拼字符串如下
String sql = "select min(a.id) from blogs where a.dayinfo='" + date + "'";

解决方案 »

  1.   

    String 变量;
    String sql ="select  a.id from blogs a where not exists (select * from message b where a.dayinfo = '"+变量+"' and a.id >b.id)"
      

  2.   

    借用楼上的一下!!
    String sql = "select top 1 a.id from blogs as a where a.dayinfo='" + date + "'"; 
      

  3.   

    String 变量;
    String sql ="select top 1 a.id from blogs a where not exists (select * from message b where a.dayinfo = '"+变量+"' and a.id >b.id)"
      

  4.   

    这样写出错:java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]无法绑定由多个部分组成的标识符 "a.dayinfo"。
    这是什么原因啊?
      

  5.   

    a是在括号外面定义的。所以会出错。
    String 变量; 
    String sql ="select top 1 a.id from blogs a where not exists (select * from message b,blogs a where a.dayinfo = '"+变量+"' and a.id >b.id)"