Actually the sql statement you want is

select whatever from articles where textlines regexp "^\Sbingo\S$"

regards

Jon
--
Jon Farmer
Systems Programmer, Entanet www.enta.net
Tel 01952 428969 Mob 07763 620378
PGP Key available, send email with subject: Send PGP Key


----- Original Message -----
From: "Warren Vail" <[EMAIL PROTECTED]>
To: "Michael Hall" <[EMAIL PROTECTED]>; "PHP List"
<[EMAIL PROTECTED]>
Sent: Thursday, November 29, 2001 2:57 PM
Subject: RE: [PHP] database question


Try;

SELECT whatever FROM articles WHERE textlines LIKE "%searchword%"

Two warnings;

1) This will force a "table scan" (the contents of each row in the entire
table because there can be no index to support faster searching of contents
that float in the column) which will be very slow on a large database (even
a medium size one).
2) This will also find words that exist inside other words. (ie the word
"ward" exists inside "toward")  If you try to solve this by imbedding blanks
between the wildcard (%) and the text, you will probably not be able to find
the word at the end of a line, or just prior to a comma or period.

I also believe there may be a way to make the search case insensitive, look
for something like a " WHERE tolower(textlines) LIKE ..." to force the
column values to be all lower case and make sure your search values are all
lower case as well.

Good luck,

Warren Vail

-----Original Message-----
From: Michael Hall [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 29, 2001 2:21 PM
To: PHP List
Subject: [PHP] database question


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
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://openlearningcommunity.org



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to