Created
January 16, 2019 09:32
-
-
Save czwen/fd60d6e131a41760bb8ae3f074268c9b to your computer and use it in GitHub Desktop.
mysql 版本字符串比较
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 获取小于等于12.0.2版本的最新数据 | |
SELECT *, CONCAT( | |
LPAD(SUBSTRING_INDEX(SUBSTRING_INDEX(version, '.', 1), '.', -1), 5, '0'), | |
LPAD(SUBSTRING_INDEX(SUBSTRING_INDEX(version, '.', 2), '.', -1), 5, '0'), | |
LPAD(SUBSTRING_INDEX(SUBSTRING_INDEX(version, '.', 3), '.', -1), 5, '0')) vcode | |
FROM foo | |
having vcode <= CONCAT(LPAD(12,5,'0'), LPAD(0,5,'0'), LPAD(2,5,'0')) | |
order by vcode desc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment