首页 > 解决方案 > 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');

标签: phpmysqllaravelmysqli

解决方案


试试这个

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');

推荐阅读