Solved

Avoid records with underscore

Posted on 2014-11-27
1
110 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
Comment Utility
try

INSTR(jcid, '_')=0

or this one...

LOCATE(jcid, '_')=0
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

7 Experts available now in Live!

Get 1:1 Help Now