Solved

Avoid records with underscore

Posted on 2014-11-27
1
121 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
[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
1 Comment
 
LVL 53

Accepted Solution

by:
Huseyin KAHRAMAN earned 500 total points
ID: 40469029
try

INSTR(jcid, '_')=0

or this one...

LOCATE(jcid, '_')=0
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

740 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