Re: database question
| From: | Julio Nobrega Trabalhando | Date: | Thu, 29 Nov 2001 12:47:58 +0000 |
| Subject: | Re: database question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76025@lists.php.net to get a copy of this message | ||
$word = 'bingo';
$sql = "SELECT a_column FROM table WHERE text_column LIKE '%$word%';
$res = mysql_query($sql);
// etc... for displaying results
Resuming:
% on the beggining - doesn't matter what comes before
% on the end - doesn't matter what comes after
--
Julio Nobrega
No matter where you go, &this.
"Michael Hall" <admin@openlearningcommunity.org> wrote in message
news:Pine.LNX.4.21.0111300746340.1639-100000@localhost.localdomain...
>
> How can I search a MySQL database field that contains sentences (VARCHAR
> datatype) or entire texts (TEXT datatype) for single words?
>
> Let's say I want to search 100 articles stored in a database field as TEXT
> for the word "bingo", is there any SQL or PHP way of doing that?
>
> Mick
>
> --
> ################################
> Michael Hall
> admin@openlearningcommunity.org
> m.hall@latis.net.au
> http://openlearningcommunity.org
>
>