How to use alphanumeric fields with BETWEEN clause in Mysql?

吃可爱长大的小学妹 提交于 2019-12-02 09:26:48

Instead of BETWEEN clause use STRCMP(expr1, expr2) function for string comparison operations:

WHERE STRCMP(mgrs, '42SWC227821555') >= 0 AND STRCMP(mgrs, '42SWC227821570') <= 0

I will list some steps, instead of complete answer.

  1. Remove all alphabets from you value, means you can have 1 more customized column using function listed on this link
  2. Apply your filter on this column.

You can use string expressions with BETWEEN comparison.

SELECT '42SWC2278215551' BETWEEN '42SWC227821555' AND '42SWd227821555'
-> 1
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!