Solved

Like Syntax

Posted on 2004-08-06
8
3,148 Views
Last Modified: 2008-01-09
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

0
Comment
Question by:ralphsauto
  • 5
  • 3
8 Comments
 
LVL 17

Expert Comment

by:akshah123
ID: 11737451
0
 
LVL 17

Expert Comment

by:akshah123
ID: 11737464
Above page has all the wildcards allowed in mysql.

You need something like:

SELECT * FROM yourtable WHERE yourfield REGEXP '^[a-d]'
0
 
LVL 17

Expert Comment

by:akshah123
ID: 11737486
For syntax on regular expression go to:

http://dev.mysql.com/doc/mysql/en/Regexp.html
0
 

Author Comment

by:ralphsauto
ID: 11738178
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 17

Expert Comment

by:akshah123
ID: 11738365
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
 
LVL 17

Accepted Solution

by:
akshah123 earned 125 total points
ID: 11738437
For this use
>>> one can get all the records that have numbers only.

select * from your tabel where yourfield REGEXP '^[0-9]+$';
0
 

Author Comment

by:ralphsauto
ID: 11739447
The last statement you sent me doesn't work I get a bad syntax error from MySQL
0
 

Author Comment

by:ralphsauto
ID: 11739570
Sorry My mistake using perl I needed to escape the $ You have earned the points.  Thanks
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Creating and Managing Databases with phpMyAdmin in cPanel.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
A short film showing how OnPage and Connectwise integration works.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now