SELECT a.phone, from_unixtime(a.ts/1000) ,ts > 1356969601000 AND ts < 1364745599000 FROM giftcard_distinct_copy a where a.phone in( SELECT phone FROM giftcard_s ) ORDER BY a.phone asc