Solved

How do you search for you one word in field?

Posted on 2011-09-18
4
244 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 50 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

729 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