Solved

MySql with HP-UX

Posted on 2013-01-02
5
263 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 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query group by data in SQL Server - cursor? 3 49
SQL Use Distinct with two fields 3 14
Filtering characters in an SQL field 2 16
MySql Recovery 2 28
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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