gpt4 book ai didi

mysql - SQL 按门牌号订购地址

转载 作者:行者123 更新时间:2023-11-29 08:02:53 25 4
gpt4 key购买 nike

如果我有结果

11 The street
9 The street
59 The street

常规的ORDER BY ASC可以做到这一点

11 The street
59 The street
9 The street

如何通过 ASC 订购并让数字像这样计数

9 The street
11 The street
59 The street

最佳答案

请尝试:

select *
From tbl
order by cast(Left(Col, PatIndex('%[^0-9]%', Col)) as int)

SQL Fiddle Demo

对于MySql,请尝试:

select *
From tbl
order by convert(SUBSTRING_INDEX(Col, ' ', 1), UNSIGNED INTEGER)

MySql Fiddle

关于mysql - SQL 按门牌号订购地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23339278/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com