Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql 版本号比较 #149

Open
lovelmh13 opened this issue Jul 26, 2021 · 0 comments
Open

mysql 版本号比较 #149

lovelmh13 opened this issue Jul 26, 2021 · 0 comments

Comments

@lovelmh13
Copy link
Owner

取每组版本号并向前补0至N位(比方5位、10位),最后拼接好在进行比较

CONCAT(
    LPAD( SUBSTRING_INDEX( SUBSTRING_INDEX( cver, '.', 1 ), '.', - 1 ), 10, '0' ),
    LPAD( SUBSTRING_INDEX( SUBSTRING_INDEX( cver, '.', 2 ), '.', - 1 ), 10, '0' ),
    LPAD( SUBSTRING_INDEX( SUBSTRING_INDEX( cver, '.', 3 ), '.', - 1 ), 10, '0' )
) > CONCAT(
    LPAD( SUBSTRING_INDEX( SUBSTRING_INDEX( repaired_cver, '.', 1 ), '.', - 1 ), 10, '0' ),
    LPAD( SUBSTRING_INDEX( SUBSTRING_INDEX( repaired_cver, '.', 2 ), '.', - 1 ), 10, '0' ),
    LPAD( SUBSTRING_INDEX( SUBSTRING_INDEX( repaired_cver, '.', 3 ), '.', - 1 ), 10, '0' )
)

这个 sql ,每个组成部分最多可以包含10位数字。

它将转换为:X.XX.XXX > Y.YY.YYY → '000000000X00000000XX0000000XXX' > '000000000Y00000000YY0000000YYY'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant