Jump to content

Like Or Regex


Recommended Posts

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.



Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

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

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...