我有一个数据(它的ID):
SB-1
SB-10
SB-9
我的查询是
SELECT * FROM sb ORDER BY id DESC
结果是:
SB-9
SB-10
SB-1
我希望我的结果是:
SB-10
SB-9
SB-1
查询方式如何?
答案 0 :(得分:2)
以下查询应执行您想要的操作:
mutation CreateUserAndAddress {
createUserAndAddress(input1:{name:"Bala"},input2:{phone:"8745524"}) {
id
}
}
答案 1 :(得分:0)
使用SUBSTRING_INDEX
并选择一个int值,然后按
select * , cast( SUBSTRING_INDEX(column_name,'-',-1) as unsigned ) as v
from table_name order by v desc
并且需要显式转换
答案 2 :(得分:0)
以下查询应执行所需的操作:
select * , cast( replace(id,'SB-','') as int ) as newid
from tablename order by newid desc