select a.id, a.from, a.content, a.addtime from (select * from `table` where to = 'a' order by addtime desc) a group by a.from
解决方案 »
- postgres:数据库怎么停止?
- 救命啊,数据库连接不上。jsp+postgresql
- [讨论]MS sqlserver 数据库转换到MYSQL数据库
- 菜鸟求救:关于MYSQL数据导入问题
- mysql connector net 1.02BUG好多,幸好1.03改掉了几个致命的,但还有BUG,就是pool最好设为false,否则有可能会出错。
- 高手帮忙!急!
- help me!!!!我用VC编译mysql源码的libmysqld包时,一直都出错,错误是
- Help!! my postgreSQL can not start now!!!!!
- 有个疑问,为什么mysqlworkbench不支持断点调试呢
- 请教大神,一个mysql优化问题!在线等,急!!
- mySql中没有和SQL Server中一样的Schema功能啊?
- 求在windows下如何设置mysql数据库主从同步,尽量说的详细一点,这个问题已经困扰了我好几天了
from table结构如下 v
where (`from`='a' or to='a')
and not exists (select 1 from table结构如下 where (`from`='a' or to='a') and (to=v.to or to=v.from) and id>v.id)
这个试了一下,具体操作句子是这样select * from __TABLE__ v where (c_from='a' or c_to='a') and not exists (select 1 from __TABLE__ where (c_from='a' or c_to='a') and (c_to=v.c_to or c_to=v.c_from) and c_id >v.c_id)有结果出来了,但是是所有与a聊天的记录,依然有重复。
from tb v
where (`from`='a' or to='a')
and not exists (select 1 from tb where (to=v.to or from=v.from or to=v.from or from=v.to) and id>v.id)
select * from table
where id in (
select id,max(add_time) as c_id from table as T1 where T1.from = 'A' group by to
)
最后结果,分享一下!