查询今天最后一条数据
创新互联提供做网站、网站建设、网页设计,品牌网站设计,一元广告等致力于企业网站建设与公司网站制作,10余年的网站开发和建站经验,助力企业信息化建设,成功案例突破上千多家,是您实现网站建设的好选择.
SELECT * FROM `weibo_logs` where DATEDIFF( NOW(),date)=0 order by `date` desc limit 1
查询符合条件的weibo_user_id每天的一条数据
SELECT weibo_user_id, DATE_FORMAT(date,'%Y-%m-%d') FROM `text` where 'weibo_user_id'='{$source_account-id}' GROUP BY DATE_FORMAT(date,'%Y-%m-%d')
这样会有排序问题,那么就先排序
SELECT DATE_FORMAT(date,'%Y-%m-%d') as d
FROM (SELECT * FROM `text` ORDER BY date DESC) as s
where 'weibo_user_id'='{$source_account-id}'
GROUP BY DATE_FORMAT(date,'%Y-%m-%d')
SELECT * FROM 当前表
WHERE id = ( SELECT MAX( id ) FROM 当前表 WHERE userid= '10000' )
解释一下:首先括号里先查出此userid登录的所有记录,然后去max最大的id,最后把最大的id的记录查出来,即检索出上次此用户登录的信息
select a.name name1,a.*,b.value,b.* from piwik_site a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and b.name='nb_visits' and a.idsite=b.idsite order by b.value desc
如果页面显示的是这个语句,那么最后一个应该是select a.name name1,a.*,b.value,b.* from piwik_site
a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and
b.name='nb_visits' and a.idsite=b.idsite order by b.value asc limit 1
或者先执行一次select count(*) 拿到数量num,再select a.name name1,a.*,b.value,b.* from piwik_site
a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and
b.name='nb_visits' and a.idsite=b.idsite order by b.value desc limit num-1,1
可以在sql语句中进行排序,select * from tbl_rentinfo where uName='$uName' order by id desc.