AlexV
03-18-2009, 04:05 PM
Hello!
I have a very poorly written database struct that I must query...
The particular field that I'm interested contains "special" data. The data is as follow:
maker=Foo&year=2001&somevalue=abc
= and & are reserved characters so if they are present in a value they are escaped that way:
maker=Test%3Dfoo%26bar&year=2001&somevalue=abc
(%3D and %26)
Every special field have an unique name. The special field order in the database field can vary. I know this isn't the best design but I have no control over it.
Now I must get all the distinct values of a particular "field". I was thinking of using MySQL REGEXP, but I'm very bad with regular expressions.
Which MySQL regular expression would retrieve the value part of a particular special field (like "year" in my previous example)? The special field can be at the beggining of the string or at the end. It must also work correctly with things like:
someyear=2002&year=2001
(only 2001 will be found here)
Anyone can help with this regular expression? Also is there a better way than REGEXP to achieve what I want to?
Many thanks!
I have a very poorly written database struct that I must query...
The particular field that I'm interested contains "special" data. The data is as follow:
maker=Foo&year=2001&somevalue=abc
= and & are reserved characters so if they are present in a value they are escaped that way:
maker=Test%3Dfoo%26bar&year=2001&somevalue=abc
(%3D and %26)
Every special field have an unique name. The special field order in the database field can vary. I know this isn't the best design but I have no control over it.
Now I must get all the distinct values of a particular "field". I was thinking of using MySQL REGEXP, but I'm very bad with regular expressions.
Which MySQL regular expression would retrieve the value part of a particular special field (like "year" in my previous example)? The special field can be at the beggining of the string or at the end. It must also work correctly with things like:
someyear=2002&year=2001
(only 2001 will be found here)
Anyone can help with this regular expression? Also is there a better way than REGEXP to achieve what I want to?
Many thanks!