Solved

Like Syntax

Posted on 2004-08-06
8
3,162 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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