16 messages in com.mysql.lists.mysqlRe: word boundaries
FromSent OnAttachments
jm...@charm10 Dec 2000 03:40 
Jeremy D. Zawodny10 Dec 2000 10:11 
Seung-woo Nam10 Dec 2000 12:21 
jm...@charm10 Dec 2000 16:45 
Seung-woo Nam10 Dec 2000 20:42 
Trey Connell11 Dec 2000 00:46 
jmj11 Dec 2000 03:48 
Seung-woo Nam11 Dec 2000 12:46 
Trey Connell11 Dec 2000 13:24 
Stephen Woodbridge11 Dec 2000 13:26 
Steve Ruby11 Dec 2000 13:45 
Trey Connell11 Dec 2000 14:14 
Steve Ruby11 Dec 2000 14:56 
jodie11 Dec 2000 15:00 
Jim Carey15 Dec 2000 20:33 
Jim Carey15 Dec 2000 20:34 
Subject:Re: word boundaries
From:jodie (jod@csinet.com.au)
Date:12/11/2000 03:00:29 PM
List:com.mysql.lists.mysql

You can use a regex, which supports word boundaries

SELECT article_id FROM articles WHERE article_body REGEX "[[:<:]]DOG" - This would match 'DOG DOGS DOGHOUSE" etc. but not "HOTDOG"

SELECT article_id FROM articles WHERE article_body REGEX "[[:<:]]DOG[[:>:]]" - This would only match "DOG".

man 7 regex (on a GNU system) for more information on word boundaries. It's also preferable that you would store keywords (unuseful words and possibly punctuation stripped) in a seperate column to speed up the regex.

jodie.

At 06:47 11/12/00, you wrote:

Hi all, I have the latest version of MySQL running on a FreeBSD box. I need to perform a search on a table in my database that takes word boundaries into account. The specific column I am searching holds the body of articles that are uploaded. Right now I do this:

select article_id from articles where article_body like "%GE%";

This, of course, returns everything with GE somewhere in it - huGE, GEneral, GEnius - you get the idea. How can I write the query so that I only get back results where GE is found as a word by itself? The solution also needs to take into account punctuation before and after the word GE.

Thanks!

Trey

--

--------------------------------------------------------------------- Please check "http://www.mysql.com/documentation/manual.php" before posting. To request this thread, e-mail mysq@lists.mysql.com

To unsubscribe, send a message to: <mysql-unsubscribe-jodie=csin@lists.mysql.com>

If you have a broken mail client that cannot send a message to the above address (Microsoft Outlook), you can use: http://lists.mysql.com/php/unsubscribe.php