select a.row_id,a.name,b1.date from a,(select row_id,max(date) as date from b group by row_id) as b1 where a.row_id=b1.row_id;