I am trying to use todays date with cur_date() and trying to pull all the columns where it is between a datestart column and a dateend column.
I have tried both the below queries but get: Unknown column ‘tdate’ in ‘where clause’
SELECT id,
details,
CURDATE() AS tdate
FROM specials
WHERE tdate BETWEEN datestart AND dateend;
SELECT id,
details,
CURDATE() AS tdate
FROM specials WHERE datestart <= tdate AND dateend >= tdate;
This field alias is not seen in WHERE clause, try this query instead –
Or use a subquery –