Dan Venturini <mailto:[EMAIL PROTECTED]>
    on Friday, October 08, 2004 11:51 AM said:

> Now If I do a search for "cleaning mouse" I get 0 results. If I do
> "cleaning computer' I get 0 results. But If I do mouse cleaning,
> mouse, cleaning your,I get the articles.

[snip]

> My question is am I doing something wrong here? Do you have anytips on
> making a smart search work? This is the only way I was taught where
> you match the user input to something in the database.

well i think the principal is that you need to search for each word
individually, grouping them with AND. i had the same question but never
got around to working on it so i did a little investigation but came up
dry (so far).

i thought an easy way to do it would be to use the IN() function:

SELECT name
FROM products
WHERE name IN ('cleaning', 'computer')

but this doesn't work as it's looking for a name with exactly 'cleaning'
or exactly 'computer'. so i tried adding LIKE before the IN, but that's
just plain invalid. then i tried wrapping each item with % but although
it doesn't throw an error, that doesn't work either.

the only other thing i can think of (not that a better answer is not out
there of course) is to create a statement like the following:

SELECT name
FROM products
WHERE name LIKE '%cleaning%'
        AND name LIKE '%computer%'


report back to the list if you find out anything else, or if anyone
would like to chime in and answer this.



chris.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to