Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
>Supposing I have a string variable cDesc = "VIBR CHOL BIOV" and will use this as reference to retrieve all records with descriptions containing any of the 3 words in any order. If description field contains "Cholera due to Vibrio cholerae 01, biovar cholerae" or "Cholera due to Vibrio cholerae 01, biovar eltor", these records should be included in the resultset.
>
>Where description = "%"+cDesc+"%" clause is not sufficient to do the above problem.
>
>Any inputs are highly appreciated!
>
>TIA
Try something like:
Take the original string, add a leading ' and trailing %'
sFind=['VIBR CHOL BIOV%']
Replace each space with %' $ searchfld or '
sFind=['VIBR%' $ searchfld or 'CHOL%' $ searchfld or 'BIOV%']
Build your SQL string:
s = [select * from theTable where ] + sFind
which gives
select * from theTable where 'VIBR%' $ searchfld or 'CHOL%' $ searchfld or 'BIOV%'
Then execute the contents of s
&s
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement