Home  >  Article  >  Backend Development  >  MYSQL中截取数据库时间字段等于提交上来的值如何写MYSQL语句

MYSQL中截取数据库时间字段等于提交上来的值如何写MYSQL语句

WBOY
WBOYOriginal
2016-06-13 11:56:531135browse

MYSQL中截取数据库时间字段等于提交上来的值怎么写MYSQL语句
bl_time是字段(如2014-05-09 11:33:20)
$Year是表单提交上来的值(如2014)

.....where YEAR('ruku.bl_time')=" . $Year;

意思就是截取bl_time字段的年份等于表单提交上来的$Year的值
where 后面的语句怎么写才正确?
------解决方案--------------------

<br /><br />$sql = "select * from table where year(bl_time) = '$Year'";<br /><br />

------解决方案--------------------
用month() 和 day() 是没问题的,你试了吗。

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