 |
qalcool Newbie
Joined: 26 Nov 2002 Posts: 5
|
Posted: Tue Nov 26, 2002 6:54 pm
Database troubles.. |
I have a huge database (eq). And i want to find all records who has some words in first column. Just like #find do. But if i have records with 'blue steel bracelet' i cant find it using #find "blue bracelet". I mean i cant find record if my search string contains first and third word from record. How can i make it?
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Nov 26, 2002 11:52 pm |
Assuming the first column is named Name.
#QUERY (%pos(blue, &Name) AND %pos(bracelet, &Name))
LightBulb
Senior Member |
|
|
 |
qalcool Newbie
Joined: 26 Nov 2002 Posts: 5
|
Posted: Wed Nov 27, 2002 12:09 am |
I dont know exact number of words in query. It can be 'blue' it can be 'blue bracer' it can be 'blue steel bracelet'. What should i do? Sorry for so stupid question, but i`m too tired to think now, and i have to finish it in a few hours..
|
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Nov 27, 2002 2:04 am |
If you don't know what you are going to look for, who will? Once you've decided what YOU are going to look for, make a #QUERY to look for it.
LightBulb
Senior Member |
|
|
 |
qalcool Newbie
Joined: 26 Nov 2002 Posts: 5
|
Posted: Wed Nov 27, 2002 9:10 am |
let me explain. I have an alias. smth like
#alias findeq {...}
argument (%0) to this alias can be any size. It can be 'blue'. It can be 'blue bracelet'. It can be anything else. Using that argument i want to find eq record in db.
Can i form expression for #query dynamically? I mean can i create string with expression using %concat, and fit it into #query? |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Nov 27, 2002 5:54 pm |
Sorry, I can't think of any easy way to do it. It probably can be done if you're willing to put some thinking into it though.
LightBulb
Senior Member |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Nov 28, 2002 7:06 pm |
Okay, here's a solution for 1 to 4 parameters. Check carefully for typos.
#AL findeq {#IF (%numparam() = 0) {#SHOW this alias requires at least one parameter};#IF (%numparam() = 1) {#SHOW %query(%pos(%1, &Name))};#IF (%numparam() = 2) {#SHOW %query(%pos(%1, &Name) AND %pos(%2, &Name))};#IF (%numparam() = 3) {#SHOW %query(%pos(%1, &Name) AND %pos(%2, &Name) AND %pos(%3, &Name))};#IF (%numparam() = 4) (#SHOW %query(%pos(%1, &Name) AND %pos(%2, &Name) AND %pos(%3, &Name) AND %pos(%4, &Name))};#IF (%numparam() > 4) {#SHOW Too many parameters, you need to add more routines to the alias}}
LightBulb
Senior Member |
|
|
 |
Castaway GURU

Joined: 10 Oct 2000 Posts: 793 Location: Swindon, England
|
Posted: Thu Nov 28, 2002 8:47 pm |
hmm.. how about a loop over the words and building a string?
#var queryparam ''
#forall %numwords(%1) {
queryparam=%concat(@queryparam, "AND ", %pos(%word(%1, %i), &Name)
}
queryparam=%copy(@queryparam, 5, %len(@queryparam) - 5)
#show %query(@queryparam)
(untested)
Lady C. |
|
|
 |
qalcool Newbie
Joined: 26 Nov 2002 Posts: 5
|
Posted: Fri Nov 29, 2002 11:42 am |
Hmm :) I didnt think about %numparam :) Thank you.
|
|
|
 |
|
|