および関数でCASE
式を使用できます。Week()
Day()
select title,
case
when week(timestamp) = week(curdate())
then
case
when day(timestamp) = day(curdate()) +1
then 'Tomorrow'
else 'This Week'
end
when week(timestamp) > week(curdate())
then 'And Beyond'
end as Col
from yourtable
SQL Fiddle with Demoを参照してください。
または、これは次のように記述できます。
select title,
case
when week(timestamp) = week(curdate())
and day(timestamp) = day(curdate()) +1
then 'Tomorrow'
when week(timestamp) = week(curdate())
then 'This Week'
else 'And Beyond'
end as Col
from yourtable
デモで SQL Fiddle を参照してください
これは以下を返します:
| TITLE | COL |
-----------------------
| Test 1 | Tomorrow |
| Test 2 | Tomorrow |
| Test 3 | This Week |
| Test 4 | And Beyond |