Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi there

 

I need some SQL for Access that will find a string within a string

 

e.g

 

Find "Murp" in "Dr Eugene Murphys Surgery"

 

thanks

ZuBiE

Posted
Hi there

 

I need some SQL for Access that will find a string within a string

 

e.g

 

Find "Murp" in "Dr Eugene Murphys Surgery"

 

thanks

ZuBiE

InStr([start, ] searchstring, findstring[, compare])

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

  • *Experts*
Posted

You could try something like:

SELECT * FROM MyTable WHERE MyField LIKE '*Murph*'

 

Would return rows where MyField contained "Murphy Is Nice", "Is Murphy Nice" but not "Bob is Nice".

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
Maybe you could show us some code to work on ? :p

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

strSql = "SELECT Customers.CustomerCode, Customers.CustomerName, Customers.Addr1, Customers.Addr2, Customers.Addr3, Customers.Addr4, Groups.GroupName, Reps.RepName, Territories.TerritoryName, Customers.AttentionOf, Customers.PhoneNo " & _

"FROM (Groups RIGHT JOIN (Customers LEFT JOIN Reps ON Customers.RepNo = Reps.RepCode) ON Groups.GroupCode = Customers.GroupCode) LEFT JOIN Territories ON Reps.TerritoryNo = Territories.TerritoryNo "

 

strSql = strSql & "WHERE Customers.AttentionOf Like '*" & strSearch & "*'"

 

 

in this case strSearch is "Murp"

Posted

well blow me over with a feather ...

I got it ...

 

In Access you can use the * as a wild card and it works fine

BUT in .net you have to use %

 

Man but that wrecked my head!!!

 

later

ZuBiE

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...