日期函数
month(date):筛选月份
year(date):筛选年份
datediff(a.date, b.date) = 1 。
- 计算两个日期之间的差值,以天数为单位。
- 这个条件要求
a.date
和b.date
之间的差值为1天。换句话说,a.date
比b.date
晚了1天。
timestampdiff(day, a.date, b.date) = -1
- 计算两个时间戳之间的差值,可以指定不同的时间单位。
- 这个条件要求
a.date
和b.date
之间的差值为-1天。换句话说,a.date
比b.date
早了1天。
文本函数
substring_index(FIELD, sep, n)可以将字段FIELD按照sep分隔:
(1).当n大于0时取第n个分隔符(n从1开始)之后的全部内容;
(2).当n小于0时取倒数第n个分隔符(n从-1开始)之前的全部内容;
例如:180cm,75kg,27,male,可以先用substring_index(profile, ‘,’, 3)取出”180cm,75kg,27″,然后用substring_index(profile, ‘,’, -1)取出27。
当然也可以用substring_index(substring_index(profile, “,”, -2), “,”, 1)取出27。