gpt4 book ai didi

mysql - 如何搜索具有常量值的最大 id

转载 作者:太空宇宙 更新时间:2023-11-03 10:33:25 24 4
gpt4 key购买 nike

我在表中有一个 id 列,其中包含以下数据:

K1
K2
K3
....
876
765
887
K12
K13

我想找到常量“K”的最大 ID我使用了以下语法

Select max(id) from table where id like 'k%'

最终结果是K9我怎样才能得到 k13 的准确结果

最佳答案

你在哪里,试试:

Select CONCAT('K', MAX(CAST(REPLACE(id, 'K', '') AS UNSIGNED))) as maximum 
from table
where id like 'K%'

关于mysql - 如何搜索具有常量值的最大 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53514508/

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