I would like to construct a SELECT statement that can name the results based on the condition. To better explain my attempt, I constructed the following invalid / non-working statement. How could the following SELECT statement be altered to one that actually works for my cause. Thx!
SELECT
CASE
WHEN dayStart LIKE '2012-06-11%' THEN UNIX_TIMESTAMP(dayStart) as today
WHEN dayStart LIKE '2012-06-10%' THEN UNIX_TIMESTAMP(dayStart) as yest
WHEN dayStart LIKE '2012-06-12%' THEN UNIX_TIMESTAMP(dayStart) as tomor
END
FROM dayBook
WHERE userID = 1
Why not just return two columns, one that tells you the date, the other that tells you if it’s today, yesterday, or tomorrow?