截取字段的有关问题

截取字段的问题

在数据库content表中有一个字段title,title字段的每个值都包含有chateau这样的一个单词做前缀(例如:chateau   aasadf这样),现在我要写一条sql语句,对conten表中的内容进行按字母顺序排序

所以在排序的条件中应该把这个chateau前缀给去掉。。

我不知道应该怎样去掉它,我搞了半天没有搞出来,没办法,只能麻烦各位了。



降序:

select * from content order by right(title,length(title)-length(chateau)-1) desc

升序:

select * from content order by right(title,length(title)-length(chateau)-1) asc




select * from content order by substring(title,7);




或者

select * from content order by substring(title,length(chateau)+1);

截取字段的有关问题

相关文章:

你感兴趣的文章:

标签云: