Solved

MySql with HP-UX

Posted on 2013-01-02
5
262 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
5 Comments
 
LVL 34

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 37

Assisted Solution

by:Gerwin Jansen
Gerwin Jansen 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 76

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

785 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