Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do you search for you one word in field?

Posted on 2011-09-18
4
Medium Priority
?
248 Views
Last Modified: 2012-05-12
I need to search for a particular word in MYSQL.  I want to find any record with that word in a particular field.  The field can have other words, but I want to find all records with this particular word.

Additionally ... This mysql is running on my Linux dedicated box (at a co-lo) -- I currently use community edition of SQLyog to query (and modify small portions) of the database.  I'd be interested in other software that I could use for this same purpose.
0
Comment
Question by:U_S_A
[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
  • 3
4 Comments
 
LVL 23

Expert Comment

by:nemws1
ID: 36558122
This is typically done with LIKE and the wildcard "%".

% - matches 0 or more chars (like .* in regex)
? - matches a single character

You could also use the REGEXP operator, but it is typically much slower.
SELECT *
FROM mytable
WHERE some_field LIKE "%someword%'
;

Open in new window

0
 
LVL 3

Accepted Solution

by:
libby9284 earned 200 total points
ID: 36558124
Does this help?

MySql to get all rows containing hello in column mycolumn in table mytable

select * from mytable where mycolumn like '%hello%';

Open in new window

0
 
LVL 23

Expert Comment

by:nemws1
ID: 36558128
Ooops!  Sorry - the match single character in LIKE is *not* ? - it is an underscore.

For example, in this query, "something" can appear anywhere in "some_field", but only rows that also end in "CODE" followed by two characters will match.
SELECT *
FROM mytable
WHERE some_field LIKE "%something%CODE__"
;

Open in new window

0
 
LVL 23

Expert Comment

by:nemws1
ID: 36558436
Yeah... that's what I had said....
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

604 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