Home » Performance » MySQL » Making query shorter
Making query shorter [message #542] Sat, 06 January 2007 19:31 Go to next message
willybnl2  is currently offline willybnl2
Messages: 6
Registered: December 2006
Junior Member
To search within a database with a lot of text i'm now using

`column` like '%text%'

but this query will also include a lot of words I do not need.
Example:

This is a test
Istesto in abo
Test this phrase

Now when I query it with the above `column` like '%test%' i will get all three... but the 2nd is bogus.

Though i can not do
`column` like '% text%'
including a space, because it would not get the 3rd too...

So the problem is:
How to query using % % (and a third something?) so that it will also get the 3rd result (with the word at the very beginning), but that it will make sure it's a word, not part of the word.


p.s. No I can not use fulltext as the words are to short, this is the backup script if fulltext fails Smile
Re: Making query shorter [message #543 is a reply to message #542 ] Sun, 07 January 2007 05:47 Go to previous message
Peter  is currently offline Peter
Messages: 405
Registered: August 2006
Senior Member
Super Guru
First,

You can configure MySQL Full Text Search to use no stop words and have no minimum length if this is what you need for your application.

This is probably best way for you.

If not look at using regular expressions to identify you require whitespace from both sides of the string.


Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
Previous Topic:Sphinx and Mysql, Join problems!
Next Topic:InnoDB tablespace inter-version compatibility
Goto Forum:
  


Current Time: Fri Jul 10 00:32:07 EDT 2009

Total time taken to generate the page: 0.01181 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.