Re: database question
| From: | Jon Farmer | Date: | Thu, 29 Nov 2001 14:54:45 +0000 |
| Subject: | Re: database question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76039@lists.php.net to get a copy of this message | ||
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" <warren@availabletech.com>
To: "Michael Hall" <admin@openlearningcommunity.org>; "PHP List"
<php-general@lists.php.net>
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:admin@openlearningcommunity.org]
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
admin@openlearningcommunity.org
m.hall@latis.net.au
http://openlearningcommunity.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net