underscore sign in query

S

Silvio

Hello folks, I am trying to exclude record from a query that start with a
letter followed by the underscore and other letters. Example:

B_test
B_test2
B_Hello
B_Mach
B_yellow
BA
BT

In this example, I need to exclude anything that starts with B_

My understanding is to use the NOT Like function in that colum criteria such
as:

Like 'B[_]%'

However, it does not do anything (I still get all the records). I know that
underscore is in SQL is not being considered laterally. So how do I handle
this?

Thank you,
Silvio
 
J

Jerry Whittle

Are you linked to an Oracle database? The % wildcard implies so.

For Access the following will work:

Not Like "B_*"
 
S

Silvio

Hi Jerry, I am using an ODBC connection to SQL server with Microsoft Access
2007. I tried Not Like"B_*" and that excludes anything that strats with B and
not just B_

Jerry Whittle said:
Are you linked to an Oracle database? The % wildcard implies so.

For Access the following will work:

Not Like "B_*"
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Silvio said:
Hello folks, I am trying to exclude record from a query that start with a
letter followed by the underscore and other letters. Example:

B_test
B_test2
B_Hello
B_Mach
B_yellow
BA
BT

In this example, I need to exclude anything that starts with B_

My understanding is to use the NOT Like function in that colum criteria such
as:

Like 'B[_]%'

However, it does not do anything (I still get all the records). I know that
underscore is in SQL is not being considered laterally. So how do I handle
this?

Thank you,
Silvio
 
J

John Spencer

Try the following
NOT Like 'B[_]%'

Or more generally - any letter followed by an underscore
NOT Like '[a-z][_]%'

Or even more general - any character followed by an underscore
NOT Like '_[_]%'


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
S

Silvio

Jerry, it appears to work with: Not Like 'B[_]*'

Jerry Whittle said:
Are you linked to an Oracle database? The % wildcard implies so.

For Access the following will work:

Not Like "B_*"
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


Silvio said:
Hello folks, I am trying to exclude record from a query that start with a
letter followed by the underscore and other letters. Example:

B_test
B_test2
B_Hello
B_Mach
B_yellow
BA
BT

In this example, I need to exclude anything that starts with B_

My understanding is to use the NOT Like function in that colum criteria such
as:

Like 'B[_]%'

However, it does not do anything (I still get all the records). I know that
underscore is in SQL is not being considered laterally. So how do I handle
this?

Thank you,
Silvio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top