Solved

Like Syntax

Posted on 2004-08-06
8
3,175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

615 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