![](/img/trans.png)
[英]Why query not returning result and how to add thousand separator in sales column
[英]How to query fields with MySQL-Regex that contain thousand separator?
我有一个数据库表,其中包含带和不带数字的内容。 我需要找到带数字的条目。
例:
We are going to examine 1.523 data points that were collected with 2.456.213 participants.
Having an income of more than 1.000,20 Euros.
每个条目只能包含上述数字中的一种。
我尝试没有成功:
SELECT * FROM `db_content`
WHERE content REGEXP "\d{1,3}\\.\d{3}"
要么
SELECT * FROM `db_content`
WHERE content REGEXP "\d{1,3}(.\d{3})*(\.\d+)"
但它总是返回0个条目。
RegEx有什么问题?
MySQL不支持\\d
regex捕获组。 您必须使用以下之一替换:
[0-9]
[[:digit:]]
所以你的查询看起来像这样:
SELECT *
FROM `db_content`
WHERE content REGEXP '[0-9]{1,3}\\.[0-9]{3}'
-- or
SELECT *
FROM `db_content`
WHERE content REGEXP '[[:digit:]]{1,3}\\.[[:digit:]]{3}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.