Ask a Question related to ASP Database, Design and Development.
-
GH #1
String Search with SQL
I was trying to write an SQL statment that will do a string search in an
Access 2000 database. But I can't seem to figure out how to do it so
that the search is case-INsensitive. Here's the SQL I have so far:
SELECT autoQuesID,fldQuesTitle,fldBody
FROM tblFAQ_Question
WHERE fldBody LIKE '%airline%';
All this will do is search for "airline" in lower case. So if the word
"Airline" is in the field I'm searching in...it won't find it. I've
also tried this SQL statment:
SELECT autoQuesID,fldQuesTitle,fldBody
FROM tblFAQ_Question
WHERE LCase(fldBody) LIKE '%airline%';
This won't return any rows, even if there is a match in the field. Can
anyone help me out?
Thanks!
GH Guest
-
search a string for value
hi, i have a field that has descriptions for a product.. i want to do a search on this field.. but i'm getting bad results because some users... -
how to optimize a string search
I know this is more of an algorithm question but please bear with me. In my program I am checking wether a emailid exists in a list I have in... -
Search string in a file
On Wed, 15 Oct 2003, Panther wrote: # I must search string in a file ?? # How I must open file in read and search string ?? # What is syntax ??... -
String question: Returning portion of string with words surrounding highlighted search term?
I'm looking to find or create an ASP script that will take a string, examine it for a search term, and if it finds the search term in the string,... -
string search
Is there a way to search a string within a string. For example, I want to search for "world" in "Hello world" knowing that "world" can be anywhere... -
Bob Barrows [MVP] #2
Re: String Search with SQL
GH wrote:
Not according to the documentation, or my tests.> I was trying to write an SQL statment that will do a string search in
> an Access 2000 database. But I can't seem to figure out how to do it
> so that the search is case-INsensitive. Here's the SQL I have so far:
>
> SELECT autoQuesID,fldQuesTitle,fldBody
> FROM tblFAQ_Question
> WHERE fldBody LIKE '%airline%';
>
> All this will do is search for "airline" in lower case. So if the
> word "Airline" is in the field I'm searching in...it won't find it.
This code:
<%
dim cn, rs, sSQL
set cn=createobject("adodb.connection")
sSQL="Select * From Table1 WHERE [Name] Like '%home%'"
cn.open "provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("db7.mdb")
Set rs=cn.Execute (sSQL,,adCmdText)
Response.Write rs.GetString(adClipString,," | ","<BR>")
rs.Close:set rs=nothing
cn.Close:set cn=nothing
%>
produced this result:
9 | Anti-Homeopathy Illuminati | 6
According to the documentation, all searches are case-insensitive. This
statement:
Select * From Table1 WHERE [Name] = 'anti-homeopathy Illuminati'
produced the same result. It's case-sensitive searches that are hard to do.
I question whether there really is a match. Could you show us the row of> I've also tried this SQL statment:
>
> SELECT autoQuesID,fldQuesTitle,fldBody
> FROM tblFAQ_Question
> WHERE LCase(fldBody) LIKE '%airline%';
>
> This won't return any rows, even if there is a match in the field.
> Can anyone help me out?
>
data that you feel should be returned by this statement?
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows [MVP] Guest
-
GH #3
Re: String Search with SQL
Bob Barrows [MVP] wrote:
Ok, here's some data:> GH wrote:
>>>>I was trying to write an SQL statment that will do a string search in
>>an Access 2000 database. But I can't seem to figure out how to do it
>>so that the search is case-INsensitive. Here's the SQL I have so far:
>>
>>SELECT autoQuesID,fldQuesTitle,fldBody
>>FROM tblFAQ_Question
>>WHERE fldBody LIKE '%airline%';
>>
>>All this will do is search for "airline" in lower case. So if the
>>word "Airline" is in the field I'm searching in...it won't find it.
>
> Not according to the documentation, or my tests.
>
> This code:
> <%
> dim cn, rs, sSQL
> set cn=createobject("adodb.connection")
> sSQL="Select * From Table1 WHERE [Name] Like '%home%'"
> cn.open "provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=" & Server.MapPath("db7.mdb")
> Set rs=cn.Execute (sSQL,,adCmdText)
> Response.Write rs.GetString(adClipString,," | ","<BR>")
> rs.Close:set rs=nothing
> cn.Close:set cn=nothing
> %>
>
> produced this result:
> 9 | Anti-Homeopathy Illuminati | 6
>
>
> According to the documentation, all searches are case-insensitive. This
> statement:
> Select * From Table1 WHERE [Name] = 'anti-homeopathy Illuminati'
>
> produced the same result. It's case-sensitive searches that are hard to do.
>
>>>>I've also tried this SQL statment:
>>
>>SELECT autoQuesID,fldQuesTitle,fldBody
>>FROM tblFAQ_Question
>>WHERE LCase(fldBody) LIKE '%airline%';
>>
>>This won't return any rows, even if there is a match in the field.
>>Can anyone help me out?
>>
>
> I question whether there really is a match. Could you show us the row of
> data that you feel should be returned by this statement?
>
> Bob Barrows
(tblFAQ_Question.fldQuesTitle)
Row 1: Airline Phone Numbers
Row 2: How do I make changes to my airline reservations?
If I type this SQL directly into an access query, I get no results:
SELECT tblFAQ_Question.fldQuesTitle
FROM tblFAQ_Question
WHERE (((tblFAQ_Question.fldQuesTitle) Like '%airline%'));
This makes even less sense, because now it isn't even finding the row
that matches it exactly ( row 2).
GH Guest
-
Bob Barrows [MVP] #4
Re: String Search with SQL
GH wrote:
Using the Access Query Builder, you have to use the Jet wildcards (*, ?)>
> If I type this SQL directly into an access query, I get no results:
>
> SELECT tblFAQ_Question.fldQuesTitle
> FROM tblFAQ_Question
> WHERE (((tblFAQ_Question.fldQuesTitle) Like '%airline%'));
>
> This makes even less sense, because now it isn't even finding the row
> that matches it exactly ( row 2).
instead of the odbc wildcards. Your query as typed into the Query Builder
should look like this (after removing all the unnecessary parentheses and
aliases):
SELECT fldQuesTitle FROM tblFAQ_Question
WHERE fldQuesTitle Like '*airline*'
It's only when constructing the sql statement using ADO (for example from an
ASP page) that you need to use the odbc wildcards.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows [MVP] Guest
-
GH #5
Re: String Search with SQL
Bob Barrows [MVP] wrote:
You're right, when I use the * is does work in the query in access. So> GH wrote:
>>>>If I type this SQL directly into an access query, I get no results:
>>
>>SELECT tblFAQ_Question.fldQuesTitle
>>FROM tblFAQ_Question
>>WHERE (((tblFAQ_Question.fldQuesTitle) Like '%airline%'));
>>
>>This makes even less sense, because now it isn't even finding the row
>>that matches it exactly ( row 2).
>
> Using the Access Query Builder, you have to use the Jet wildcards (*, ?)
> instead of the odbc wildcards. Your query as typed into the Query Builder
> should look like this (after removing all the unnecessary parentheses and
> aliases):
>
> SELECT fldQuesTitle FROM tblFAQ_Question
> WHERE fldQuesTitle Like '*airline*'
>
>
> It's only when constructing the sql statement using ADO (for example from an
> ASP page) that you need to use the odbc wildcards.
>
> Bob Barrows
>
if I was using PHP, then I would need to use the % instead of the *?
Thanks again for your help
GH Guest
-
Bob Barrows [MVP] #6
Re: String Search with SQL
GH wrote:
I don't know. I've never used PHP. If you use ODBC or OLEDB from PHP, then I>
> You're right, when I use the * is does work in the query in access.
> So
> if I was using PHP, then I would need to use the % instead of the *?
>
> Thanks again for your help
strongly suspect that you would need to use the odbc wildcards. Can anyone
confirm this?
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows [MVP] Guest
-
GH #7
Re: String Search with SQL
Bob Barrows [MVP] wrote:
Yup, you're right. I just tried it in PHP and it works with the % and> GH wrote:
>
>>>>You're right, when I use the * is does work in the query in access.
>>So
>>if I was using PHP, then I would need to use the % instead of the *?
>>
>>Thanks again for your help
>
> I don't know. I've never used PHP. If you use ODBC or OLEDB from PHP, then I
> strongly suspect that you would need to use the odbc wildcards. Can anyone
> confirm this?
>
> Bob Barrows
>
not with the *. Thanks!
GH Guest



Reply With Quote

