search results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

search results

Post 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.
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post by ruchit »

i don't know if really understood it properly but you try this

Code: Select all

SELECT field1, field2 WHERE checkField='alimen'
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post 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.
Last edited by sebs on Mon Oct 03, 2005 5:29 am, edited 1 time in total.
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post 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[[:>:]]';
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

REGEXP

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

begining and ending word markers (from what I remember)
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post by sebs »

still not working
select macro from firme where macro REGEXP '[[:<:]]$categ[[:>:]]').
What is wrong?
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post 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.
ruchit
Forum Commoner
Posts: 53
Joined: Mon Sep 26, 2005 6:03 am

Post by ruchit »

try this

Code: Select all

"SELECT macro FROM firme WHERE macro REGEXP '[[:<:]]".$categ."[[:>:]]'; "
sebs
Forum Commoner
Posts: 97
Joined: Tue Sep 20, 2005 10:13 am

Post by sebs »

I tryed that before but it's not working.
Post Reply