Monday, 12 August 2013

Select query to retrieve text column with hyphen, comma, period and parantheses

Select query to retrieve text column with hyphen, comma, period and
parantheses

Thanks for taking time to read my question.
I have created a MySQL table, a HTML form and a program in PHP which
connects the form to MySQL table and retrieves sequences for column
Annotations which is text data type.
This column has characters and also has one or more of hyphen, comma,
parentheses, period or spaces.
Please look at the following code that I used for select query:
$values=mysql_query("SELECT Sequence
FROM oats
WHERE Foldchange = '$Foldchange' AND
RustvsMockPvalue = '$RustvsMockpvalue' AND
Annotations REGEXP '%$Annotation%[-]+'");
Here $Annotation is the form variable which holds the value entered by the
user in the form. Annotations is the column name in the MySQL table.
Annotations column has characters A-Z or a-z and one or more of hyphen,
comma, space or parentheses like the following.
Sequence is another text column in the MySQL table but does not have ,./().
Example data from Annotations column:
ADP, ATP carrier protein, mitochondrial precursor (ADP/ATP translocase)
(Adenine nucleotide translocator) (ANT).
I am not able to retrieve Sequence column data when I search for any
Annotations column data with comma, parentheses, period and slash. It
works fine for those records which does not have these ,.()/.
I tried to use LIKE instead of REGEX but it didn't work either.
Could someone please help me in the correct syntax of the SELECT syntax?

No comments:

Post a Comment