我要查找姓名(txtname.text="张三")最后一次去差(txtid.text),可以按出差记录(ID)的最大来查询.

解决方案 »

  1.   

    是说张3有个ID,最大的ID是他最后一次出差的ID
      

  2.   

    open "select * from tabel where" & txtname.text="张三" & " and id=" & max(id) ;
    楼主不会是这个意思吧
      

  3.   

    啊?条件是:1。txtname.text="张三"
                2。id=" & max(id)
    对吗?
      

  4.   

    楼主这样写试试看:
    "select * from table where" + textname.text + "='张三' group by" + txtname.text + "having max(" + id ")"
      

  5.   

    不知道这样行不行,还有种办法就是
    "select id from table where textname.text ='张三' group by txtname.text having max(id)"
    得到最大的id值,然后通过id来查找所要的记录
    因为觉得你这个txtname.text应该是表里面的属性,我改成这样了,
    如果是控件名的话那还是上面的写法。
      

  6.   

    yenight(老烟虫)的办法也不错啊,先select一张textname.text ='张三'的表,然后找这张表里最大的id号嘛
      

  7.   

    "select top 1 * from tabel where txtname="张三" order by id desc
      

  8.   

    jinesc(http://jinesc.com) 正解:sql="select top 1 * from tabel where txtname= '张三' order by ID desc"