zubie Posted August 5, 2004 Posted August 5, 2004 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 Quote
Joe Mamma Posted August 5, 2004 Posted August 5, 2004 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]) Quote 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.
zubie Posted August 5, 2004 Author Posted August 5, 2004 how do I use that in a select statement? I am using the SQL to fill a dataset to pass back Quote
*Experts* Nerseus Posted August 5, 2004 *Experts* Posted August 5, 2004 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 Quote "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
zubie Posted August 5, 2004 Author Posted August 5, 2004 OK I tried that, it works fine in Access but when I execute it from .net it isnt returning any rows? any ideas why? Quote
Arch4ngel Posted August 5, 2004 Posted August 5, 2004 Maybe you could show us some code to work on ? :p Quote "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
zubie Posted August 5, 2004 Author Posted August 5, 2004 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" Quote
zubie Posted August 6, 2004 Author Posted August 6, 2004 Hi All I'm still trying to figure out why like doesnt work when used in ASP.NET Anyone out there know why? Quote
zubie Posted August 6, 2004 Author Posted August 6, 2004 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 Quote
Administrators PlausiblyDamp Posted August 6, 2004 Administrators Posted August 6, 2004 If you copy the contents of strSql to the clipboard after building up this query can you then make it work in access? when you say it doesn't work - how does it not work (error messages, no results returned etc)? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.