Like Syntax

Using access you can differentiate between numbers and letters using - [Purchases].[Lot]) Not Like '*[a-z]*' - Using this syntax in Access one can get all the records that have numbers only.  Using this you get numbers only and only 4 placings ([Purchases].[Lot]) Not Like '####'

Is there a way to do this in MySQL

ralphsautoAsked:
Who is Participating?
 
akshah123Connect With a Mentor Commented:
For this use
>>> one can get all the records that have numbers only.

select * from your tabel where yourfield REGEXP '^[0-9]+$';
0
 
akshah123Commented:
Above page has all the wildcards allowed in mysql.

You need something like:

SELECT * FROM yourtable WHERE yourfield REGEXP '^[a-d]'
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
akshah123Commented:
For syntax on regular expression go to:

http://dev.mysql.com/doc/mysql/en/Regexp.html
0
 
ralphsautoAuthor Commented:
Ok that has helped a little, I am having trouble with the matching still 12345 is still being matched with CA12345 I just want to match 12345, I have used ^[0-9], to match the beginning of the line which just finds the first number (unless I have it wrong) [^0-9] matches alphabetic characters and any other extraneious ones in the complete line,  All in all I am gettting very confused.
0
 
akshah123Commented:
well if you do

SELECT '12345' REGEXP '[0-9]{5}';

will return true but

SELECT 'CA12345' REGEXP '[0-9]{5}';

will return false. Following will also return false since there are only 4 digits instead of 5.

SELECT '1234' REGEXP '[0-9]{5}';

0
 
ralphsautoAuthor Commented:
The last statement you sent me doesn't work I get a bad syntax error from MySQL
0
 
ralphsautoAuthor Commented:
Sorry My mistake using perl I needed to escape the $ You have earned the points.  Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.