[英]How to use REGEXP in MySQL to aquire specific columns
Recently I tried without successes asking MySQL DB for specific data: 最近,我尝试不成功地向MySQL DB询问特定数据:
SELECT code, txt_gb, txt_de
FROM table
WHERE code REGEXP 'chol'
OR txt_gb REGEXP 'chol'
OR txt_de REGEXP 'chol'
ORDER BY code
COLLATE utf8_unicode_ci
I read somewhere that LIKE command has better performance that REGEXP. 我在某处读到LIKE命令比REGEXP具有更好的性能。 Is it true?
是真的吗 Can I use LIKE in this case instead of REGEXP to find a part of cell?
在这种情况下,可以使用LIKE代替REGEXP来查找单元格的一部分吗? I am very interested in minimizing the load on the DB.
我对最小化数据库负载非常感兴趣。
try 尝试
SELECT code, txt_gb, txt_de FROM table WHERE code like '%chol%' OR txt_gb like '%chol%' OR txt_de like '%chol%' ORDER BY code
yes Regex is slow at time, like is not faster even, but works well and easy to write then regex for your need. 是的正则表达式在时间上很慢,甚至不是更快,但是可以很好地满足您的需要,并且易于编写正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.