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

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

WBOY
Release: 2016-06-13 11:56:53
Original
1159 people have browsed it

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 />
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template