多列字符串提取数字进行排序
order by e.community_code, e.estate_id, cast(cour.court_name as UNSIGNED) , cast(b.build_name as UNSIGNED) , cast(u.unit_name as UNSIGNED) ,cast(f.floor_name as UNSIGNED) , cast(a.house_no as UNSIGNED)
<select id="getByAddressPage" resultType="com.easy.hotel.pms.api.entity.House">
select
e.estate_id ,
e.estate_name,
a.house_id,
a.house_no,
a.court_id,
a.build_id,
a.unit_id,
a.floor_id,
a.house_sort,
a.house_name,
a.address,
a.built_area,
a.use_area,
a.house_type,
a.curdsts,
a.flag,
a.ty_id,
e.community_code,
a.in_time
from house a
left join build_floor f on a.floor_id = f.floor_id
left join build_unit u on a.unit_id = u.unit_id
left join build b on a.build_id = b.build_id
left join court cour on a.court_id = cour.court_id
inner join estate e on a.estate_id = e.estate_id
<where>
and a.estate_id = #{estateId}
and a.del_flag = 0
<if test="keyword != null and keyword != ''">
and (
a.house_name like concat( '%', #{keyword}, '%')
or a.address like concat( '%', #{keyword}, '%')
)
</if>
</where>
GROUP BY a.house_id
order by e.community_code, e.estate_id, CAST(cour.court_name as int) , cour.court_name , CAST(b.build_name as int) , b.build_name , CAST(u.unit_name as int) , u.unit_name , CAST(f.floor_name as int) , f.floor_name , CAST(a.house_no as int), a.house_no
</select>
MySQL从字符串提取数字_john5205的博客-CSDN博客_mysql提取字符串中的数字
MySQL从字符串提取数字
https://www.jb51.net/article/233959.htm
MySQL 字符串转换为数字的方法小结
更新时间:2022年01月07日 11:32:02 作者:平定马小跳
这篇文章主要介绍了MySQL字符串转换为数字的几种方法,本文给大家列列举了三种方法,每种方法通过实例代码给大家介绍的非常详细,需要的朋友可以参考下
方法一:直接 加 0
select '123' + 0
方法二:函数 convert
语法:convert (value, type);
type可以为:
1 2 3 |
|
select convert('123',signed)
方法三:函数 cast
语法:cast (value as type);
type可以为:
1 2 3 |
|
select cast('123' as signed)
补充:下面看下mysql 字符串转数字的三种方式
方式一:+0
方式二:cast('字符串' as 数值类型)
数值类型,可以分为三种:
整数 : SIGNED
无符号整数 : UNSIGNED
浮点数 : DECIMAL
方式三:convert('字符串', 数值类型)
数值类型,同样可以分为三种:
整数 : SIGNED
无符号整数 : UNSIGNED
浮点数 : DECIMAL
到此这篇关于MySQL 字符串 转换 为数字 的几种方法的文章就介绍到这了,更多相关MySQL 字符串 转换 为数字内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章: