2012-07-16 25 views
6

"/site/index?sid=18&sub=321333&tid=site.net&ukey=1234543254" gibi bir metin var.Grup, alt dizgeye göre

Bunu, dizenin bir parçası ile nasıl gruplandırabilirim ('sid' url param örn.)?
Ve parametreler farklı bir sırada olabilir

cevap

11

MySQL string fonksiyonları bir göz atın (hat ve vb ucunda sid):.

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

Özellikle bu yararlı görünmektedir:

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substring-index

GÜNCELLEME

Bu istedi tam olarak ne:

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX("/site/index?sid=18&sub=321333&tid=site.net&ukey=1234543254", 'sid=', -1), '&', 1) AS this_will_be_grouped 

ve Sorgunuzun GROUP BY yan tümcesinde this_will_be_grouped kullanmak