Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query searches excluding input strings

Status
Not open for further replies.

IcePak

Technical User
Nov 7, 2001
23
US
Hello.

My second posting of the day is in regards to exlcuding certain entries by means of a query. After searching this forum, I came across the <> operator.

This allowed me to run a query that would exlude all entries containing a inputted word. The only problem is that it will only return entries that dont have the word character by character.

What I mean is that I want it to search a field for let's say &quot;hello&quot; and exclude that entry whether the corresponding cell has &quot;hello&quot; or &quot;xhellox&quot; or &quot;hello goodbye&quot;.

Now I know how do this to include it.
You use the Like &quot;*&quot; & [Form]![Formname]![InputText] & &quot;*&quot; statement.
I just can't find a (easy) way to incorporate that methodology with the exclusion one.

I obtain syntax errors when trying to combine <> and Like &quot;*&quot;.

Any help would be grand, thanks.
Mike
 

Try the INSTR function. It searches for a string in a string or column. If not found, it returns zero.

Select * From TableName
Where INSTR(ColName,&quot;hello&quot;)=0 Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 

I forgot to mention that you can also use NOT LIKE.

Select * From TableName
Where ColName Not Like &quot;*hello*&quot; Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top