Solved

Like Syntax

Posted on 2004-08-06
8
3,166 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP: Insert Data into MySQL 5 61
insert row field data graphically 4 33
MySQL limit and not so limited 13 34
mysql qry 1 21
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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 …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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