Solved

Avoid records with underscore

Posted on 2014-11-27
1
115 Views
Last Modified: 2014-11-27
Hi experts,

I need to perform a mysql query to retrieve all records that not contains an underscore into a string.
So 12345 should be taken ; 12345_blue should be rejected.

I use the following query but it is to much time consumming (due to the use of LIKE)
select jcId from jcstktabl where jcid not like '%\_%'

Open in new window


I would like to replace this with a version without like clause, for performance concern.

EDIT : I know using like with a leadind joker is bad, but I don't find another way :(

Thanks a lot
0
Comment
Question by:adam1h
1 Comment
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40469029
try

INSTR(jcid, '_')=0

or this one...

LOCATE(jcid, '_')=0
0

Featured Post

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.

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…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
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…

803 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