开发者

I want to select a particular list of words containing certain characters using php

开发者 https://www.devze.com 2023-01-03 01:16 出处:网络
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 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.开发者_JS百科 It works if I give in the full text.

Thanks Jean


Try the following:

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


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%'";


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


SELECT * FROM para WHERE para_main LIKE '%text_words%'
0

精彩评论

暂无评论...
验证码 换一张
取 消