php - Need to get records using day between from day and to day
问题描述
How can I get records from database using only day name. I have a column in the database which is from_day
and to_day
.
If I pass Tue
then I need result where from
is less Tue
(like Mon
), and end
is greater (like Wed
).
For example, if I pass Tue
then I need records where the column should have Mon
as from_day
and to_day
should be Wed
or Tue
.
I have tried this:
SELECT booking_times.* FROM booking_times WHERE 'Tue' BETWEEN
DATE_FORMAT(booking_times.from_day, 'D') AND
DATE_FORMAT(booking_times.to_day, 'D');
解决方案
试试这个
SELECT booking_times.* FROM booking_times WHERE DATE_FORMAT(booking_times.from_day, 'enter day') AND DATE_FORMAT(booking_times.to_day, 'enter to day');
推荐阅读
- java - 如何在java中使用私钥-RSA算法解密消息
- mysql - 按日期过滤 SQL 结果
- android - 计算孩子中的值的数量以检查重复数据
- c# - Azure函数-“从文档中提取的PartitionKey与标题中指定的不匹配”在门户中创建的容器上
- java - kafka 复制因子小于代理计数
- python - wiki dump 只提取关于人、书、地方的文章
- javascript - 集成 Parse-SDK-JS 以响应反式应用程序
- c# - 将 protobuf-net RuntimeTypeModel 与 GrpcClient (AddCodeFirstGrpcClient) 一起使用
- sql - 如何在 b 中没有函数(a)的情况下连接表
- reactjs - 传递给子组件的道具在构造函数和 componentDidMount() 中为空