RE: [PHP] database question

From: Date: Thu, 29 Nov 2001 14:57:24 +0000
Subject: RE: [PHP] database question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-76035@lists.php.net to get a copy of this message
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

« previous php.general (#76035) next »