jgingras Posted April 17, 2008 Posted April 17, 2008 For finding the records starting with a specific letter im using the LIKE 'a%' for example. But what would I do to find a record where the first character of a field is not a letter.. Thanks, -Jacques Quote
TCH-Andy Posted April 17, 2008 Posted April 17, 2008 You don't say what language you are using, but general regex would be negated with a ^ so for none alpha it would be ^a-zA-Z Quote
jgingras Posted April 17, 2008 Author Posted April 17, 2008 Oops... using mysql... Lets say the Field name is CustName what would be the syntax? Only looking for the first character. Thanks Quote
MikeJ Posted April 18, 2008 Posted April 18, 2008 You should be able to do the same thing in MySQL as you do for letters: LIKE '1%' Quote
dcumpian Posted April 18, 2008 Posted April 18, 2008 You should be able to do the same thing in MySQL as you do for letters: LIKE '1%' You can also search for records CONTAINING an alphanumeric string by using LIKE '%string%'. Regards Quote
jgingras Posted April 18, 2008 Author Posted April 18, 2008 Right, I've been using the LIKE to search for strings in other areas, but I what im doing is listing contacts by the first letter of their name/company name. I have links for A through Z but some start with numbers or other characters and I was going to have that be its own link. So for each letter, im doing LIKE 'a%' etc.. through z.. but im looking for a name that doesn't start with a letter. so I dont think that LIKE would work.. Maybe im wrong.. but if someone could help me with the syntax that would be great. Again, what im looking for is to find CustName where the first letter is not a letter. Thanks.. Quote
MikeJ Posted April 18, 2008 Posted April 18, 2008 Sorry, I misunderstood and thought you were looking for a specific first number. Then you want something like this: >SELECT * FROM sometable WHERE CustName REGEXP '^[0-9]'; And if you wanted everything that doesn't start with a number: >SELECT * FROM sometable WHERE CustName NOT REGEXP '^[0-9]'; ^ = beginning of string (not negate like Andy suggested) in standard regular expressions. Quote
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.