Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how can i built this query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-19 : 12:22:10
Manish writes "hi
how r u
here i need ur help


i am working on one project in which i create search engine which search data in database.

during the product search, i enter a string in textbox and click go, this string is go to asp page and their i split it for search with diffrent way...

strKeyword = split(Trim(Request("searchs")), " ")

now suppose the database content product like this

chloro amino benzene
chloro amino phenol
chloro amino acetic acid
chloro aminoacid
chloro acetic acid
chlorophil
chlorobenzene
chloro amino benzoic acid

so when i enter "chloro" for search it give result all this product listed above

if i enter "chloro a" for search at that time i would like to get result of this product....

chloro amino benzene
chloro amino phenol
chloro amino acetic acid
chloro aminoacid
chloro amino benzoic acid

and if i enter "chloro amino b" i want result like ....

chloro amino benzene
chloro amino benzoic acid

for that i use the this coding ....

Select Case UBound(strKeyword)
Case 0 rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' order by Product_sell desc", con, adOpenForwardOnly, adLockReadOnly, adCmdText
Case 1 rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' and Product_sell like '" & strKeyword(1) & "%' order by Product_sell desc", con
Case 2 rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' and Product_sell like '" & strKeyword(1) & "%' and Product_sell like '" & strKeyword(2) & "%' order by Product_sell desc", con
Case Else rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' and Product_sell like '" & strKeyword(1) & "%' and Product_sell like '" & strKeyword(2) & "%' order by Product_sell desc", con

End Select

here i make some mistake so i can't get the result which i want,
so please help me and solve my probleam

i also want to ignor numeric value and any type of symbol (like & * ( ) ! @ # $ % { } { [ ] , . / _ - = + " ' : ; and numaric value 0 to 9)
for that what change i have to make in this code

it means if some one enter "2 chloro amino benzene" or "2-chloro amino benzene" or "4, chloro amino benzene" or "2:chloro amino benzene" etc... different way it reflact chloro amino benzene in result, ignor numaric value 2 or 4 and also symbol "-" or "," or ": "
hope u understand what i mean to say, right

the another question is

i have some company name such as...

cadila pharmaceutical limited
bayer ag ltd
shanghai intermediates ltd
anand chemical and intermediates pvt ltd

now i want query which select first char of string's each word. means

for cadila pharmaceutical limited i want "cpl"
for bayer ag ltd i want "bal"
for shanghai intermediates ltd i want "sil"
for anand chemical and intermediates pvt ltd i want "acaipl"

hope u understand which type of query i want
so please reply me soon

solve my probleam and reply me soon
as early as possible
ok

manish"

mAdMaLuDaWg
Starting Member

42 Posts

Posted - 2002-06-19 : 17:53:17
quote:

Manish writes "hi
how r u
here i need ur help


i am working on one project in which i create search engine which search data in database.

during the product search, i enter a string in textbox and click go, this string is go to asp page and their i split it for search with diffrent way...

strKeyword = split(Trim(Request("searchs")), " ")

now suppose the database content product like this

chloro amino benzene
chloro amino phenol
chloro amino acetic acid
chloro aminoacid
chloro acetic acid
chlorophil
chlorobenzene
chloro amino benzoic acid

so when i enter "chloro" for search it give result all this product listed above

if i enter "chloro a" for search at that time i would like to get result of this product....

chloro amino benzene
chloro amino phenol
chloro amino acetic acid
chloro aminoacid
chloro amino benzoic acid

and if i enter "chloro amino b" i want result like ....

chloro amino benzene
chloro amino benzoic acid

for that i use the this coding ....

Select Case UBound(strKeyword)
Case 0 rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' order by Product_sell desc", con, adOpenForwardOnly, adLockReadOnly, adCmdText
Case 1 rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' and Product_sell like '" & strKeyword(1) & "%' order by Product_sell desc", con
Case 2 rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' and Product_sell like '" & strKeyword(1) & "%' and Product_sell like '" & strKeyword(2) & "%' order by Product_sell desc", con
Case Else rs.Open "select * from m where Product_sell like '" & strKeyword(0) & "%' and Product_sell like '" & strKeyword(1) & "%' and Product_sell like '" & strKeyword(2) & "%' order by Product_sell desc", con

End Select

here i make some mistake so i can't get the result which i want,
so please help me and solve my probleam

i also want to ignor numeric value and any type of symbol (like & * ( ) ! @ # $ % { } { [ ] , . / _ - = + " ' : ; and numaric value 0 to 9)
for that what change i have to make in this code

it means if some one enter "2 chloro amino benzene" or "2-chloro amino benzene" or "4, chloro amino benzene" or "2:chloro amino benzene" etc... different way it reflact chloro amino benzene in result, ignor numaric value 2 or 4 and also symbol "-" or "," or ": "
hope u understand what i mean to say, right

the another question is

i have some company name such as...

cadila pharmaceutical limited
bayer ag ltd
shanghai intermediates ltd
anand chemical and intermediates pvt ltd

now i want query which select first char of string's each word. means

for cadila pharmaceutical limited i want "cpl"
for bayer ag ltd i want "bal"
for shanghai intermediates ltd i want "sil"
for anand chemical and intermediates pvt ltd i want "acaipl"

hope u understand which type of query i want
so please reply me soon

solve my probleam and reply me soon
as early as possible
ok

manish"


I think you would be better off posting on an ASP forum. Try www.gotdotnet.com or www.asphole.com

Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-06-20 : 11:56:22

With the keyword search, I've done something almost exactly like that.
This is the article that I used to create my search.

http://www.sqlteam.com/item.asp?ItemID=5857

You really need to move your data access code to stored procs, and then call those stored procs from ASP.

With the second question, that's a bit tougher. I know you'll need to use substring to find the right parts. The article above has some examples on how to use substring, so that should put you in the ballpark.

Michael


Go to Top of Page
   

- Advertisement -