页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

...

代码块
languagesql
collapsetrue
/*mysql.help_topic  是MySQL的一个内置表,内置了600多条数据
其中存在一个整形的序号字段 help_topic_id  借助此字段处理成当前月的每一天数据
如11月有30条数据如,10月有31条数据,11月有30条数据*/

select * from (
select
    date_sub(
        curdate(),
        interval(cast(help_topic_id as signed integer)) day
    ) as dates,
    year(
        date_sub(
            curdate(),
            interval(cast(help_topic_id as signed integer)) day
        )
    ) year,
    month(
        date_sub(
            curdate(),
            interval(cast(help_topic_id as signed integer)) day
        )
    ) month,
    day(
        date_sub(
            curdate(),
            interval(cast(help_topic_id as signed integer)) day
        )
    ) day
from
    mysql.help_topic
where
    help_topic_id < day(curdate())
union all
select
    date_add(
        curdate(),
        interval(cast(help_topic_id as signed integer)+1 ) day
    ) as dates,
    year(
        date_add(
            curdate(),
            interval(cast(help_topic_id as signed integer)+1 ) day
        )
    ) year,
    month(
        date_add(
            curdate(),
            interval(cast(help_topic_id as signed integer)+1 ) day
        )
    ) month,
    day(
        date_add(
            curdate(),
            interval(cast(help_topic_id as signed integer)+1 ) day
        )
    ) day
from
    mysql.help_topic
where
    help_topic_id < day(last_day(curdate())) - day(curdate())
    ) t order by dates

...