Fix the SQL WHERE condition when request Timelines