Home  >  Article  >  Database  >  mysql 关于limit 子查询和获取某当天所有记录_MySQL

mysql 关于limit 子查询和获取某当天所有记录_MySQL

WBOY
WBOYOriginal
2016-06-01 13:51:50927browse

今天写MYSQL 当有个需求用到limit 在子查询下使用。郁闷了竟然过不去。但只要转化就就可以。真是悲剧。

update tbl

 set isoption=1 where  userguid='sss'  pid in(select pid from tbl  where activeid=1 and isoption=0  limit 3) 语法过不去 但是

update tblp set isoption1 where userguid='sss' and pid in(select t.pid from( select pid   from tblpromotion where activeid=1 and isoption=0  limit 3) as t )

就可以。所以不明白其内部是如何优化SQL语句的。

获取当天信息

SELECT count(1) as num FROM tblcdkey  WHERE  DATE_FORMAT(providetime,'%Y-%m-%d')=DATE_FORMAT(NOW(),'%Y-%m-%d')

比t-sql方便。

 

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn