求一条查询语句

table:
id date message userno
1 2017-11-16 16:02:40 hi zhangsan 13100000007
2 2017-11-16 16:00:11 hi lisi 13100000007
3 2017-11-17 16:00:11 hi wangwu 13100000008

我想查找出账号13100000007的总记录数,还有最新的一条记录
怎样查出如下结果:
count message date
2 hi zhangsan 2017-11-16 16:02:40

阅读 2.2k
3 个回答

select (select count()from table where id='378754' )message,date from table order by date desc limit 1

SELECT COUNT(*) as count, message, date FROM table WHERE id=13100000007 ORDER BY date DESC LIMIT 1

select (select count(*) from table where id='13100000007') as 'count',message,date from table order by date desc limit 1

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题