Connecting Tech Pros Worldwide Forums | Help | Site Map

Find "11*" in a table, but not 11* using a wildcard

Newbie
 
Join Date: Oct 2007
Posts: 14
#1: Oct 2 '07
I have another newbie question for you guys... I apologize in advance for how simple it is...

I've got a string of data, included in that string is 11* as it appears, the * is not a wildcard. I'm using the function

Like "*" & "11*" & "*" to find any records that have "11*", again, the * is not a wildcard. But it's interpreting it as a wildcard, so I'm getting 1105 and 11X and so on. How can I change the formula so that it will return 11* in the middle of the string?

Thanks in advance for the help.

ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,224
#2: Oct 2 '07

re: Find "11*" in a table, but not 11* using a wildcard


Quote:

Originally Posted by BlackJack17

I have another newbie question for you guys... I apologize in advance for how simple it is...

I've got a string of data, included in that string is 11* as it appears, the * is not a wildcard. I'm using the function

Like "*" & "11*" & "*" to find any records that have "11*", again, the * is not a wildcard. But it's interpreting it as a wildcard, so I'm getting 1105 and 11X and so on. How can I change the formula so that it will return 11* in the middle of the string?

Thanks in advance for the help.

Avoid the confusion with treating the * Wildcard as a Literal. This will accomplish exactly what you are requesting, but only specifying an explicit Criteria instead of using the Like Operator:
Expand|Select|Wrap|Line Numbers
  1. InStr([Your String],"11*") > 0
Newbie
 
Join Date: Oct 2007
Posts: 14
#3: Oct 2 '07

re: Find "11*" in a table, but not 11* using a wildcard


Can I put that on the Criteria line of my query? Or do I put it somewhere else?
Newbie
 
Join Date: Nov 2007
Location: Linden, NJ
Posts: 1
#4: Nov 7 '07

re: Find "11*" in a table, but not 11* using a wildcard


Select * From TABLENAME Where substr(FIELDNAME,1,3) = '11*'

Substitute TABLENAME and FIELDNAME according to what table and field your looking at.
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,224
#5: Nov 7 '07

re: Find "11*" in a table, but not 11* using a wildcard


Quote:

Originally Posted by goodmanstl7

Select * From TABLENAME Where substr(FIELDNAME,1,3) = '11*'

Substitute TABLENAME and FIELDNAME according to what table and field your looking at.

goodmanstl7, there is no substr Function that I am aware of. Are you referring to the Transact-SQL Function SubString()?
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,224
#6: Nov 8 '07

re: Find "11*" in a table, but not 11* using a wildcard


Quote:

Originally Posted by BlackJack17

Can I put that on the Criteria line of my query? Or do I put it somewhere else?

Assuming you are looking for the String '11*' anywhere in the [LastName] Field of tblEmployees:
  1. You can place it in the Criteria Row of the Query Grid, in this demo in the [LastName] Field:
    Expand|Select|Wrap|Line Numbers
    1. InStr([LastName],"11*")>"0"
  2. You can place it in an SQL Statement directly and return all Records meeting the Criteria:
    Expand|Select|Wrap|Line Numbers
    1. SELECT tblEmployeePFD.LastName, *
    2. FROM tblEmployeePFD
    3. WHERE ((InStr([LastName],"11*")>"0"));
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,002
#7: Nov 8 '07

re: Find "11*" in a table, but not 11* using a wildcard


Just out of curiosity, ADezii, could you have used

Expand|Select|Wrap|Line Numbers
  1. InStr([LastName],"11" & Chr(42))>"0"
as well?

Linq ;0)>
ADezii's Avatar
Expert
 
Join Date: Apr 2006
Location: Philadelphia
Posts: 5,224
#8: Nov 9 '07

re: Find "11*" in a table, but not 11* using a wildcard


Quote:

Originally Posted by missinglinq

Just out of curiosity, ADezii, could you have used

Expand|Select|Wrap|Line Numbers
  1. InStr([LastName],"11" & Chr(42))>"0"
as well?

Linq ;0)>

Sorry Linq, don't know how I missed this one but InStr([LastName],"11" & Chr(42))>"0" will work equally as well.
Reply