现要查询一个表,并得到符合下面二个条件中message中的内容;首先要找到符合条件字段(user),假如这个字段的内容为‘FA’;则满足第一个条件,第二个条件是,是这个表中满足第一个条件后,最后一个存入的数据(我这里用编号来判断;字段名为:send_id);之后我要将满足这两个条件的数据中的message内容附值给sendmessage;我是这样写的:
with adoquery1 do
begin
close;
sql.clear;
sql.add('select * from tsendm where max(send_id) and user='+quotedstr('FA'));
open;
sendmessage:=fieldbyname('message').asstring;
end;
不知道以上对不对,有其它看法的朋友提一下意见,因为没有装数据库,自已不好测试,所以写出来让大家看一下是否有问题,
with adoquery1 do
begin
close;
sql.clear;
sql.add('select * from tsendm where max(send_id) and user='+quotedstr('FA'));
open;
sendmessage:=fieldbyname('message').asstring;
end;
不知道以上对不对,有其它看法的朋友提一下意见,因为没有装数据库,自已不好测试,所以写出来让大家看一下是否有问题,
——————————
不需要用max(send_id),order by desc 倒序排列
这样第一条记录就是“最后一个存入的数据”
‘select * from tsendm where user='+quotedstr('FA')+‘ order by desc’