From: john.holmes Date: June 21 2000 2:44pm Subject: Re: Re: [Mysql] regular expression problem List-Archive: http://lists.mysql.com/mysql/41122 Message-Id: If you are using PHP, you can get the whole textfield from mysql, then run extract($textfield); and it will create all of your $key=$value pairs... $a = 12 $b = 16 $c = 42 if ($a > 100) { ... } If you can't find a way to do it in the actual SQL query, this could be an option? if not, spend my $0.02 on something nice.. :) ---John Holmes Richard Ellerbrock wrote: > >All,> >I have a text field with the following string > >+--------------------+ >| textfield | >+--------------------+ >| a=12,b=16,c=42,e=2 | >+--------------------+ > >I need an expression to check this field - first for the presence of a key >("a") >and also if it has an assignment equal to or greater than a value ie. >"a=100". > >Using the above examples, basically the required output should be as >follows > >Success: > >+-----------------------+ >| textfield | >+-----------------------+ >| a=112,b=126,c=425,e=2 | >+-----------------------+ > >+---------------------+ >| textfield | >+---------------------+ >| a=100,b=16,c=42,e=2 | >+---------------------+ > >Fail: > >+--------------------+ >| textfield | >+--------------------+ >| a=12,b=16,c=42,e=2 | >+--------------------+ > >I know it's unorthodox but if this could be done it would dramatically >reduce >the frontend workload. I don't know why your data is stored that way, but if you always have an a, b, c, and e, why not put them in seperate columns (normalize the data)? This would simplify things tremendously and all that would be required then is to use an expression in a WHERE clause (WHERE a > 100). You can then also index the information. You can still display the info any way you wish using concat() to build the output the way you wish. Remember that using REGEX in a database negates the use of an index on that column, so if you have lots of data, queries are going to take very long. -- Richard Ellerbrock richarde@stripped -- --------------------------------------------------------------------- Please check "http://www.mysql.com/php/manual.php3" before posting. To request this thread, e-mail mysql-thread41107@stripped To unsubscribe, send a message to: