Solved

MySql with HP-UX

Posted on 2013-01-02
5
265 Views
Last Modified: 2013-01-02
Hello,
I'm trying to use a simple mysql query using the where option.  I looked at a manual that I have and I can't this statement to work.  I wonder if there is some setting I am missing.
This statement works; select service from XXXinstances where service='XXX_3';
There are many of each X types.  There are X_1, XX_2, and XXXX_4, etc.
I'm trying to use a wide card %, like this;
select service from XXXinstances where service='%_3';
To select all of the _3 types/services.
Why does this not work?
0
Comment
Question by:chima
[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
5 Comments
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 250 total points
ID: 38736985
With a wild card, you need to switch from = to LIKE.  Your query should be this:

select service from XXXinstances where service like '%_3';
0
 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 50 total points
ID: 38736992
Can you try using like instead of =

... where service like '%_3';

edit: after posting I saw the above 2 replies..
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 200 total points
ID: 38737014
Even with the LIKE syntax above beware that the '_' is a single character wildcard so it will match 'abcdef3'.

You will need to escape the '_'.

select ... like '%\_3';

http://dev.mysql.com/doc/refman/5.0/en//string-comparison-functions.html
0
 

Author Closing Comment

by:chima
ID: 38738799
Thanks
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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