问题描述
我有一个字段,内容如 /site/index?sid=18&sub=321333&tid=site.net&ukey=1234543254
。
如何将它分成部分字符串(' sid
'url param eg)?
和params可以按不同的顺序排列( sid
在行尾等)
查看MySQL字符串函数:
特别是这看起来很有用:
更新
这正是您所要求的: (SUBSTRING_INDEX(/ site / index?sid = 18& sub = 321333& tid = site.net& ukey = 1234543254)。 ,'sid =',-1),'&',1)AS this_will_be_grouped
并在<$ $中使用 this_will_be_grouped
c $ c> GROUP BY 您的查询条款
I have a field with text like "/site/index?sid=18&sub=321333&tid=site.net&ukey=1234543254
".
How can I group it by part of string( 'sid
' url param e.g.)?
And params may be in a different order.(sid
on the end of line and etc.)
Take a look at the MySQL string functions:
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html
Especially this looks helpful:
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substring-index
UPDATE
This is exactly what you asked for:
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX("/site/index?sid=18&sub=321333&tid=site.net&ukey=1234543254", 'sid=', -1), '&', 1) AS this_will_be_grouped
and use this_will_be_grouped
in the GROUP BY
clause of your query
这篇关于按子串分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!