-
search condition in MS Access
Hai,
May I know the query to how to create a "exact word" search condition using MS Access database in my program, which uses ASP as a scripting language.
-
Select *
From YourTable
Where SomeField = 'A_Word'
-
search condition
hai,
Sorry,let me make the scenario clear. I want a search condition ,like how the search condition will work in the "search box" in the websites. Mine is a net shopping project and if the customer wants something specific, my search should search in my database table for that exact word and yield the result.
-
That's what this sample query is telling you:
Select *
From YourTable
Where SomeField = 'A_Word'
The "Where SomeField = 'A_Word'" is the search criteria portion of the query. "A_Word" is representative fo the user entered word(s).
In ASP code you would need a search form:
Code:
<form action="/SearchResults.asp" method="get">
<b>Search By Keyword(s): </b>
<br>
<input type="text" size="15" name="keywords" id="keywords" maxlength="50" value="<%=Request("keywords")%>"> <input type="submit" value="Go">
</form>
Then in SearchResults.asp, you would build your SQL Query:
Code:
Dim SQL
If Len(Trim(Request("Keywords"))) > 0 Then
SQL = "Select * From MyTable Where KeywordField Like '*" & Trim(Request("Keywords")) & "*'"
End If
Then output the results to the page.
-
Hai, it is not working
Hai.
That query is not working, but neither it shows an error. It simply displays as if there was no data present matching the search criteria. But if I put % instead it is working, but yielding all the results. For ex, if i put "men", it is giving the result for "women" too, because men is included in women. So will u please clarify that. Thanks a lot in advance.
-
What version of Access are you using? I think only the newest version uses % as the wildcard operator. Prior to that Access used * as the wildcard operator.
If you don't want to do pattern matching, then simply do this:
Dim SQL
If Len(Trim(Request("Keywords"))) > 0 Then
SQL = "Select * From MyTable Where KeywordField = '" & Trim(Request("Keywords")) & "'"
End If
-
Again again the same probs
Hai,
Thank u Mr. Rawhide for ur replies. But i want only the exact word outputs. Can't we do that in the newer version of the MS Access. I'm using the latest version xp.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|