Page 1 of 1

search results

Posted: Mon Oct 03, 2005 3:07 am
by sebs
I am working on some search results from a database and I have encountered the next problem:
If it is entered Alimentation I have to find all the results,if it is entered "alimen" all the results for the exact word alimen(not alimentation).
The problem is in the database I have strings like Alimentation Company,Home Delivery.Could you help with this because I can't use LIKE or substr().
I have searched for topics like this but none helped me.

Posted: Mon Oct 03, 2005 4:12 am
by ruchit
i don't know if really understood it properly but you try this

Code: Select all

SELECT field1, field2 WHERE checkField='alimen'

Posted: Mon Oct 03, 2005 5:07 am
by sebs
i will say this different:
how can I search a field without using LIKE.
I have in one field:
[Alimentation,Delivery]
If I enter Alimentation I need to find that field between the results.
If I enter Alimen that field it's not in the result I am searching for.
I can't say where checkfield='alimentation' because it will find me nothing
I can't say where checkfield LIKE 'alimen' because it will find me that field and I don't want that.
If it's entered 'alimen' I need to be able to say that no results are found and if it's entered 'alimentation' I need to find this result.

Posted: Mon Oct 03, 2005 5:25 am
by ruchit
if I am getting you right this time around you can perhaps take a look at

Code: Select all

SELECT col1, col2 FROM Table WHERE checkCol REGEXP '[[:<:]]word[[:>:]]';

REGEXP

Posted: Mon Oct 03, 2005 6:42 am
by sebs
This is not working but could be a solution if I change it a little.Could you tell me what [[:<:]] means?I haven't found that.

Posted: Mon Oct 03, 2005 6:43 am
by feyd
begining and ending word markers (from what I remember)

Posted: Mon Oct 03, 2005 7:04 am
by sebs
still not working
select macro from firme where macro REGEXP '[[:<:]]$categ[[:>:]]').
What is wrong?

Posted: Mon Oct 03, 2005 7:35 am
by sebs
I have found another way.If you still know a easier way just tell me.
I know that in my case I don't have anything but spaces between words so:
$categ=$categ." ";
I use: where macro like '%$categ%';
This way I search only for the whole words.

Posted: Tue Oct 04, 2005 1:40 am
by ruchit
try this

Code: Select all

"SELECT macro FROM firme WHERE macro REGEXP '[[:<:]]".$categ."[[:>:]]'; "

Posted: Tue Oct 04, 2005 3:37 am
by sebs
I tryed that before but it's not working.