那也就是最大日期那条记录了?试下: select * from tb_name a where not exists (select 1 from tb_name b where substring_index(b.v_path,'\\',-2)>a.substring_index(b.v_path,'\\',-2))
select max(left(substring_index(v_path,'\\',-2),8)) from tab_rec
select v_path from tab_rec where left(substring_index(v_path,'\\',-2),8) =(select max(left(substring_index(v_path,'\\',-2),8)) from tab_rec)
select * from tb_name a where not exists (select 1 from tb_name b where substring_index(b.v_path,'\\',-2)>a.substring_index(b.v_path,'\\',-2))
数据库表tab_rec,有字段v_path, 类型是varchar(255),内容形如d:\temp\20091116\,其中20091118是日期;
有个结构跟tab_rec一样的表tab_rec_copy,内容形式雷同tab_rec的v_path
还有个表tab_bak,其中有字段v_srcdir怎样从tab_rec和tab_rec_copy两表中找到离当前日期最近的v_path,且该v_path值不存在于表tab_rec的v_srcdir
有个结构跟tab_rec一样的表tab_rec_copy,
还有个表tab_bak,其中有字段v_srcdir ,内容形式雷同tab_rec的v_path 怎样从tab_rec和tab_rec_copy两表中找到离当前日期最近的v_path,且该v_path值不存在于表tab_rec的v_srcdir
from tab_rec
where substring_index(v_path,'\\',-2)=(select max(substring_index(v_path,'\\',-2)) from tab_rec)