我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

PHP - mysqli_query - WHERE和日期

I have a PHP query that I only want to select if the date is 2014 in the table:

$result=mysqli_query($linkID, "SELECT * FROM table WHERE date(Y) = '2014'";

I'm trying to call "date(Y)" with the correct expression as that is obviously incorrect.

Use this:

$result=mysqli_query($linkID, "SELECT * FROM table WHERE YEAR(datetime_field) = 2014");

the query should be

SELECT * FROM table WHERE YEAR(the_date_field) = 2014

the_date_field is the field containing the date of course

近期文章

  • 将MySQL结构导入实时SQL数据库
  • mysqli_query获取空结果
  • Jquery UI滑块事件不起作用Drupal 7
  • 为什么这些Xpath元素不是一个数组?
  • Laravel 4 - 通过hasMany关系插入
  • 我应该在购买物品的表格中有产品的外键吗? [关闭]
  • 无法从FOREACH循环中正确显示结果
  • 一个sql语句优于两个?
  • 单击链接时如何对表升序和降序进行排序
  • 从客户提供的时间戳(和时区)获取适当的时间
  • 有没有比使用echo更好的显示结果的方法
  • 是否可以将PHP与HTML“Value”属性一起使用
  • 使用函数更改复选框上的div内容单击不起作用
  • 如何只显示具有匹配数组键的数组值?
  • array_sum结果为负数
  • 需要Mcrypt PHP扩展
  • 基于之前下拉列表的下拉列表
  • 如何将键值对存储在.csv文件中,然后将它们作为关联数组检索?
  • infowindow的Google Maps V3 API链接
  • 如何打印超链接ONCE?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华