One column returns such values:
一列返回这样的值:
Something";s:5:"value";s:3:"900";s:11:"print_
I want to extract all numbers that are at least 3 digits long, in the above case thats 900. How can I do that in MySQL? Maybe using a regex? I cant use any index, the length of the string and the number in the string can be different.
我想提取所有至少3位数的数字,在上面的情况下是900.我怎么能在MySQL中做到这一点?也许使用正则表达式?我不能使用任何索引,字符串的长度和字符串中的数字可以不同。
Thanks!
2 个解决方案
#1
0
Try unserialize() it if you are using PHP! And then var_dump it to see the strings and arrays
如果你使用PHP,请尝试unserialize()它!然后var_dump它来查看字符串和数组
#2
0
You can't extract them using MySQL, use any other language for that. What you can do is include a Where Clause, that will make the work easier for your script.
你不能使用MySQL提取它们,使用任何其他语言。你可以做的是包括Where子句,这将使你的脚本的工作更容易。
Assuming your column is called "serialized" in the table "example"
假设您的列在表“示例”中被称为“序列化”
SELECT serialized FROM example WHERE serialized REGEXP '[0-9]{3,}'
Please note that REGEXP is just outputting 1 or 0
请注意,REGEXP只输出1或0
After you did the query, use the regex functions of your language do extract the numbers like so:
在您执行查询后,使用您的语言的正则表达式函数确实提取数字,如下所示:
([0-9]{3,})*
#1
0
Try unserialize() it if you are using PHP! And then var_dump it to see the strings and arrays
如果你使用PHP,请尝试unserialize()它!然后var_dump它来查看字符串和数组
#2
0
You can't extract them using MySQL, use any other language for that. What you can do is include a Where Clause, that will make the work easier for your script.
你不能使用MySQL提取它们,使用任何其他语言。你可以做的是包括Where子句,这将使你的脚本的工作更容易。
Assuming your column is called "serialized" in the table "example"
假设您的列在表“示例”中被称为“序列化”
SELECT serialized FROM example WHERE serialized REGEXP '[0-9]{3,}'
Please note that REGEXP is just outputting 1 or 0
请注意,REGEXP只输出1或0
After you did the query, use the regex functions of your language do extract the numbers like so:
在您执行查询后,使用您的语言的正则表达式函数确实提取数字,如下所示:
([0-9]{3,})*