tags:

views:

36

answers:

4

Hello,

I want to select a particular list of words in a paragraph containing certain characters

$query_search_text= "SELECT * FROM para where para_main='%text_words'";

I tried using the % sign, but it does not work. It works if I give in the full text.

Thanks Jean

+1  A: 

The % is just a wildcard, and is valid only for a LIKE comparison. The query you've written will select all rows where para_main begins with the string "text_words".

If you want to allow other characters both before and after, you'll have to use:

$query_search_text= "SELECT * FROM para where para_main LIKE '%text_words%'";
VoteyDisciple
I tried that, but does not work
Jean
not sure about mysql, but in standard SQL you have to use LIKE for the wildcards to be used and not =
Cobusve
Read my answer above.
RobertPitt
Good catch. The eye sees what it wants to see, I guess. I've edited to correct.
VoteyDisciple
+4  A: 

Try the following:

$query_search_text= "SELECT * FROM para where para_main LIKE '%text_words%'";
yes, silly me thanksI can accept this answer only after 12 minutes???I need to accept it now, send me a pm or something so that I remember to accept
Jean
A: 

Its actually!

$query_search_text = "SELECT * FROM para where para_main LIKE '%text_words%'";

I also would advise you is too look at FullText searching. http://devzone.zend.com/article/1304

RobertPitt
A: 
SELECT * FROM para WHERE para_main LIKE '%text_words%'
Neb