pgSql, mySql中字符串转化为数字

pgSql

语法 to_number(text, text)

例子 select to_number(trim(both 'ibs' from classname), '999999') as cn from bbs order by cn   /*trim(both 'ibs' from classname)去除classname字段中的'ibs'字符*/

mySql

语法 str*1 / str+1 / -str  /*str为varchar的数字,此处不一定是1,只要是数字即可*/

hql

语法 to_number(text, text)

 

例子 select b from BBS b where b.isDeleted=false order by to_number(trim(both 'ibs' from b.className), '999999')

 

 

 

pgSql数据类型格式化函数 

posted on 2012-06-14 15:43  timelyxyz  阅读(2628)  评论(0编辑  收藏  举报

导航