select top 1 * from a order by id(主键) desc

解决方案 »

  1.   

    插入用append 函数;
    读取最后一条用last函数;
    比如你用ado连接数据库
      
      adoquery.close;
      adoquery.sql.clear;
      adoquery.sql.add('select *from tt');//tt为库中的表
      adoquery.open;
     
     //插入到记录尾部
      adoquery.append;
      adoquery.fieldbyname('jj').asstring:='kk';//jj为数据域名,类型要对应;
      adoquery.post;
    当然也可用with  do语句,但我建议你不要用!
     
      adoquery.close;
      adoquery.sql.clear;
      adoquery.sql.add('select *from tt');//tt为库中的表
      adoquery.open;
     
      //读取
      adoquery.last;
      ll:=adoquery.fieldbyname('nn').asstring;
    假如用open函数打不开数据库,就试用execsql函数了!
    祝你好运!
      

  2.   

    --try
    select top 1 * from 表 关键字 desc
      

  3.   

    --掉了 order by 
    select top 1 * from 表 order by 关键字 desc