使用concat()函数
例如:查询task表中task_progress字段为8,并且创建时间距离当前时间的天数大于arragement_valid_days字段中的数字天数。那么就可以使用contact()函数直接取出字段内容。
select r.* from t_task r where r.task_progress=8 and TIMESTAMPDIFF(DAY, created_time,NOW())>= concat(r.arrangement_valid_days) order by id asc
同样,也可以通过这种方式实现模糊查询和字段内容匹配的数据。
select area_code from dm_area_hide a where "4832" like concat('%',area_code,'%');