Click to See Complete Forum and Search --> : Like Operator for Access db in Asp
shanuragu
06-26-2003, 04:54 AM
Hi
How can I use Like operator to search string entered in the txt box for access db in asp.
The query statement I have used is as follows :
Select * from ItemTable Where item_nm Like '"&Inm&"%'
Inm is a form field value.
For this query I am getting syntax error.
ShaRa
bloke
06-26-2003, 06:33 AM
Try this
<%
strsearch = "SELECT * FROM tbltable WHERE (tbltable.field1 LIKE '%"& strstring1 &"%' or tblsearch.field2 LIKE '%"& strstring2 &"%') AND tbltable.field3 = false;"
response.write strsearch
response.end
%>
Cheers
Bullschmidt
06-30-2003, 01:44 AM
And just for reference here are some more Like options:
All except blanks:
Like '%'
Starting with A:
Like 'A%'
Or could do this: Like 'a%'
A somewhere in the field:
Like '%A%'
Or could do this: Like '%a%'
One character an A or B or D:
Like '[A,B,D]'
Or could do this: Like '[a,b,d]'
One character A through C as the first character:
Like '[A-C]%'
Or could do this: Like '[a-c]%'
A through C as the 1st character and A through H as the 2nd character:
Like '[A-C][A-H]%'
Or could do this: Like '[a-c][a-h]%'
Starting with Sm, ending with th, and anything for the 3rd character:
Like 'SM?TH'
Or could do this: Like 'sm?th'
Digit for the 1st character:
Like '#%'
Or could do this: Like '[0-9]%'
Not in a range of letters:
Like '[!a-c]'
Not start with a range of letters:
Like '[!a-c]%'
Not start with a number:
Or could do this: Like '[!0-9]%'