Solved

Avoid records with underscore

Posted on 2014-11-27
1
113 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

929 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

10 Experts available now in Live!

Get 1:1 Help Now