从日期大于或等于今天的mysql表中选择记录 [英] Select record(s) from mysql table where date is greater than or equal to today

查看:60
本文介绍了从日期大于或等于今天的mysql表中选择记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个项目中,该项目在数据库中具有包含日期​​的行.我想回显日期等于或大于今天的字段的数据.我看过其他文章,并尝试了许多不同的方法,但尚未成功.当前,当我执行> =时,我所返回的错误,但是当我只对下面的语句执行=时,我从数据库中获取了所有行.

I am working on a project that has rows in the database that contains a date. I want to echo the data for the fields that have a date that is equal or greater to today. I have looked at other post and tried a lot of different methods and have yet to succedd. Currently what I have returns an error when I do >= but when I just do = with the statement below, I get all rows from the database.

  $sql = "SELECT * FROM drives WHERE ddest = '{$trimmed}' AND 'leave_date' => DATE_FORMAT(CURDATE(), '%m/%d/%Y') LIKE '%$trimmed%' ORDER BY timeago DESC";

推荐答案

尝试一下

  $sql = "SELECT * FROM drives WHERE ddest = '{$trimmed}' AND 'leave_date' >= NOW() LIKE '%$trimmed%' ORDER BY timeago DESC";

否则,

  $sql = "SELECT * FROM drives WHERE ddest = '{$trimmed}' AND 'leave_date' >= DATE_FORMAT(CURDATE(), '%m/%d/%Y') LIKE '%$trimmed%' ORDER BY timeago DESC";

这篇关于从日期大于或等于今天的mysql表中选择记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆