Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Search by each word in a phrase
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01331706
Message ID:
01331803
Vues:
7
This message has been marked as a message which has helped to the initial question of the thread.
>>maybe copy and paste problem but that doesn't make any sense to me:
>>myField1 like word1 or myField1 like word1
>>
>>(the same for word2 :-))
>>
>>And you want Field1 and Field2 to BEGIN with these words, right?
>
>:) LOL. Actually, there are more than 2 fields. Here is what I want:
>
>I may type one word or two words or any number of words (I would guess 4 words would be maximum). One of the words could be a telephone number, in this case I'd like to search telephone fields for this word. It could be numeric, in this case I'd like to search ZIP field or Address1/Address2 for starting with this number.
>
>It could be just name, in this case I'd like to search FirstName, MiddleName, LastName, ScreenName, Address1/Address2/Email fields.
>
>So assuming I passed word1 and word2 and both words are character strings (not IsNumeric http://www.berezniker.com/content/pages/sql/microsoft-sql-server/isnumericex-udf-data-type-aware )
>I would use an expression like this
>
>select * from People where (Address1 like word1% or Address2 like word1% or ...) AND (Address1 like word2% or Address2 like word2% or ...)
>
>You see what I mean?
>
>BTW, I guess it's exactly the same logic as Michel uses for Member Search and other searches.
>Thanks again.
>
>May be he can share his implementation idea.


And how you could recognize what are you searching if you pass just a list?
Are '12345678, 555577777' ZIP codes or phones or both?
Why not build the whole SELECT at your front end with proper WHERE clause and the send it to SQL Server?
You know where the user enters the search word and know what type is it, ZIP, Phone, Address1 or 2, names

But use parameters:
lcSELECT = [SELECT .... FROM People WHERE ]
** Now because you know WHAT user wants
lcSELECT = lcSELECT + [ Zip = ?Par1]
etc.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform