Hi,
this is a question related to querying a table in MYSql
.I have a table with two fields.
1. item_id which is an auto number
2. item_data which is a mediumText field.

The field Item_data stored contains html data.
That is there is some relevent data along with the data for formatting the useful data.

Now my problem is that i would like to do a keyword search in the item_data field.
My problem is that if i use the normal select query like

select * from table where item_data LIKE "%keyword%"

results are returned even if the data inside the html tage contains the necessary keywords.

I understand that I can use regular expression to do the search.

Can someone give me the regular exprerssion as I am no good in making regular expressions.I even tried but could not get the desired results.

I want to search only the data and not the html.

Is there any way by which this can be accomplished.
Will be very greatful for a reply.
Thanks/Regards
Sanket Gupta

    You might not need regex's, what about just something like

    select * from table where item_data LIKE ">%keyword%<"

    That way, I think, it would search for your key word but only between a closing and an opening tag. Obviously, there will be issues with this if your data has angle brackets in it, but maybe it will help some.

      Hi,
      Thanks for the help.
      Acyually i had also tried this initially and like you i think this must work absolutely fine.
      But it did not.
      when i used this syntax no results were returned.
      I suppose both of us are missing out on something that mysql thinks is important.

      Thanks for the help
      Regards
      Sanket Gupta

        Write a Reply...