LIKE question - is it possible?

2005-04-14 Thread Micha Berdichevsky
Hi group.
I have a table with a varchar(250) column in it (let's call it c)
I want to select values that contain a number of given words in them 
(three or more), in any words order
I currently use
SELECT * FROM table WHERE c LIKE %word1%word2%word3%;
I was wandering if it is possible to use a query where the LIKE (or 
anything else) searches for my given strings in any order.
I'm using MySQL 4.1.11 on windows XP, if it matters.

Thanks.
Micha.

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


Re: LIKE question - is it possible?

2005-04-14 Thread Alec . Cawley
Micha Berdichevsky [EMAIL PROTECTED] wrote on 14/04/2005 12:53:31:

 Hi group.
 I have a table with a varchar(250) column in it (let's call it c)
 I want to select values that contain a number of given words in them 
 (three or more), in any words order
 I currently use
 SELECT * FROM table WHERE c LIKE %word1%word2%word3%;
 I was wandering if it is possible to use a query where the LIKE (or 
 anything else) searches for my given strings in any order.
 I'm using MySQL 4.1.11 on windows XP, if it matters.

I think you want to do a FULLTEXT search: see
http://dev.mysql.com/doc/mysql/en/fulltext-search.html

This requres using a FULLTEXT index on your column and using the MATCH 
command.

Alec



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



RE: LIKE question - is it possible?

2005-04-14 Thread mel list_php
I think that if you explode your words with AND it should work in any order:
SELECT * FROM table WHERE c LIKE '%word1%' AND c LIKE '%word2%' AND c LIKE 
'%word3%';

but there's maybe something better to do!

From: Micha Berdichevsky [EMAIL PROTECTED]
To: mysql@lists.mysql.com
Subject: LIKE question - is it possible?
Date: Thu, 14 Apr 2005 13:53:31 +0200
Hi group.
I have a table with a varchar(250) column in it (let's call it c)
I want to select values that contain a number of given words in them (three 
or more), in any words order
I currently use
SELECT * FROM table WHERE c LIKE %word1%word2%word3%;
I was wandering if it is possible to use a query where the LIKE (or 
anything else) searches for my given strings in any order.
I'm using MySQL 4.1.11 on windows XP, if it matters.

Thanks.
Micha.

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

_
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

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


Re: LIKE question - is it possible?

2005-04-14 Thread Stefan Kuhn
Not sure if your query works. But what should work is
SELECT * FROM table WHERE c LIKE %word1% and c LIKE %word2% and c LIKE 
%word3%;
But might be slow ...


Am Thursday 14 April 2005 13:53 schrieb Micha Berdichevsky:
 Hi group.
 I have a table with a varchar(250) column in it (let's call it c)
 I want to select values that contain a number of given words in them
 (three or more), in any words order
 I currently use
 SELECT * FROM table WHERE c LIKE %word1%word2%word3%;
 I was wandering if it is possible to use a query where the LIKE (or
 anything else) searches for my given strings in any order.
 I'm using MySQL 4.1.11 on windows XP, if it matters.

 Thanks.
 Micha.

-- 
Stefan Kuhn M. A.
Cologne University BioInformatics Center (http://www.cubic.uni-koeln.de)
Zülpicher Str. 47, 50674 Cologne
Tel: +49(0)221-470-7428   Fax: +49 (0) 221-470-7786
My public PGP key is available at http://pgp.mit.edu

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