I'm getting an error that I'm not being able to solve. I'm rather new at SQL, so I imagine this is quite an idiotic error, but I'd really appreciate somebody's help with this.
I'm trying to see if there are rows in a certain table that were created in the current week (From monday on). So I wrote this.
SELECT
*,
DATE_SUB(CURRENT_DATE,INTERVAL ( DAYOFWEEK(CURRENT_DATE) - 2 ) DAY) AS `week_start`,
CASE WHEN `ganador`.`fecha` >= `week_start` THEN 0 ELSE 1 END AS `this_week`
FROM `lesaffre_ganadores` as `ganador`
I'm getting the following error:
1054 - Unknown column 'week_start' in 'field list'
I assume there is a way to define the variable week_start in order to be able to use it in the query, but I really ignore it.
Could anyone help me?
Thank you very much!