mysql detail query string, like wildcard

孤者浪人 提交于 2019-12-06 13:22:36
SELECT * FROM `foo` WHERE `value` REGEXP "test_example-[:digit:]+"

That should work for test_example-[0-9]. More on Character Classes and REGEXP

With your given query, it would be:

SELECT MAC, NAME FROM HOST WHERE NAME REGEXP CONCAT(LEFT(NAME, LENGTH(NAME)-1), "[0-9]+") AND MAC="some mac address"

Note there is an error in your posted query - you have two WHERE clauses.

You could try to use a regexp, though I don't know how efficient it will be. You might want to do it in code rather then in sql. but still:

SELECT * FROM `foo` WHERE `value` REGEXP "yourRegexp"

Just create any regexp that satisfies your needs.

You can use an underscore character as the wildcard for a single character.

"test_example-_"
where substring(field,locate('-',field)+1,1) in ('1','2','3','4','5','6','7','8','9','0')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!